Hi Gaspard,

> I have been working on a networking library (for art and music) that
> requires very low latency (http://rubyk.org/oscit). Due to some issues
> with raw UDP (reliability, packet size), I am thinking on switching to 0mq
> because its model is very close to what I do with the library (async,
> distributed, fast, network & local).
> 
> Anyway, my question is:
> 
> How is a location such as ("tcp://10.0.0.2:4532") used internally by 0mq
> (if the remote is not yet turned on for example) ?

        I'll leave this to others but it depends on the zmq_socket type you
pass in as to what happens.

> How hard would it be to support ZeroConf so that users can refer to the
> devices by their service name 'my super synth' instead of fixed IP and
> port ?
> 
> In the last question I am only concerned by the 'locator' resolution code.
> Is it callback based ? Does it ping ?

        I use ZeroConf in conjunction with 0mq without any problems.  The
real trick is platform dependency since for Win32/OsX you will use Bonjour
and for Linux you are most likely going to use Avahi which has a completely
different API.  (Avahi has a compatibility header but it is barely
functional.)

        So far my usage has been pretty simple and there are some problems
which I've not gotten around to working on or bothering the list with.  For
instance, I want to bind to any available port and then get the port back
after the bind, I don't believe this is exposed by zmq_socket_getoption or
related.  It was easy enough to just start at a port number and loop on bind
till I got a success though, not a huge issue though kind of ugly.

        As to zeroconf+0mq, it's fairly simple.  This a unit test from my
wrapper but should give you an idea of how it can work:

// Register a service.
ZeroConf::RequestRef    tempTest        =       zeroConf.Register(
        "Panther",
        "_test._tcp",
        1235,
        &RegisteredCallback );

        As long as you hold onto "tempTest" your service is registered for
anyone on the local domain to see (and any wan domains you've registered
with).  The callback is optional, it just tells you when the advertisement
has been made, kinda useless but this is just unit test code.

        In order to find services, you just browse for them:

ZeroConf::RequestRef    browseRequest   =       zeroConf.Browse(
"_test._tcp", &BrowseCallback );

        You will get a callback for every instance of "_test._tcp" on your
network (unique instances that is).  Choose one of those and then you just
resolve it:

ZeroConf::RequestRef    resolved        =       zeroConf.Resolve(
        name,   // From the browse callback.
        "_test._tcp",
        NULL, // Or from the browse callback.
        &ResolveCallback );

        The resolve callback will give you hostname and port information
which you can pass into 0mq connect calls with a little string manipulation.


        Now, I have to warn you that the wrapper around zeroConf is not the
easiest thing in the world to write.  You need to watch for socket activity
in order to know when to call DNSServiceProcessResult and issue the
callbacks.  Also, the mentioned platform differences make for a real pain in
the ass since Avahi is so much more complicated for some reason.

        For any further zeroconf stuff it should probably be taken off list.
The 0mq stuff obviously is for others to answer.

KB

_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to