[zeromq-dev] Disconnecting from permanently dead endpoints
Martin Lucina
martin at lucina.net
Thu Jan 26 08:28:08 CET 2012
On Thu, 26 Jan 2012 17:50:19 +1100
john skaller <skaller at users.sourceforge.net> wrote:
>
> On 26/01/2012, at 2:54 PM, Martin Lucina wrote:
>
> >
> > I would go with just calling unbind() or disconnect()
> > with the char* you originally passed to bind() or connect().
>
> That's exactly what I said :)
>
> >
> > Semantics are pretty much the same; it is obviously an error to unbind
> > () or disconnect() an endpoint which was not bound or connected in the
> > first place.
>
> You may be right, however that's not what my spec says:
> when you disconnect you are disconnecting a SET of endpoints.
>
> This is because connect/bind can be called with a char* to a buffer
> which can be memcpy() into with the end point name. So all such
> endpoints have the same char* address.
*click* Oh, I get it - saw the void * and didn't realise you wanted to
use the char * address as a handle to the endpoint. Neat trick, but
rather too far in terms of overloading for my taste.
Also, it won't work terribly well for language bindings since it relies
on a string also being a pointer, which just happens to be the case for
C.
What I have in mind is more conventional: ZeroMQ takes a copy of the
string passed to bind() or connect(), stashes it in the socket. unbind
() or disconnect() are again passed a string, trawl thru all the
bound/connected endpoints for the socket, and succeed if a match is
found.
> So since you're disconnecting a SET .. well there's nothing wrong
> with an empty set!
>
> Instead, the number of matched endpoints is returned by the function.
> The client can then decide if 0 is an error or not.
Sure, this makes sense if the char * is also considered as a handle. If
it's just a string then there is no set involved since it is an error
to bind or connect[1] to the same endpoint more than once.
-mato
[1] Actually, Martin Sustrik tells me you can probably connect (but not
bind) more than once to the same endpoint in the current
implementation, but that makes no real sense anyway so should return an
error if it does not already.
--
Martin Lucina <martin at lucina.net>
More information about the zeromq-dev
mailing list