On 13 Apr 2015, at 22:50, Jens Alfke <[email protected]> wrote:

> There’s probably an alternative way to run a listener/server socket, which 
> could be scheduled on a dispatch queue, but I’m not too handy with BSD 
> network APIs and I’ve never looked at dispatch_io. Anyone got any sample code 
> or snippets?

There are two options here:

A. low-level -- Using BSD Sockets listen() and accept() with dispatch event 
sources to get the required async behaviour.

B. NSNetService -- On modern systems NSNetService can listen for incoming 
connections via the NSNetServiceListenForConnections flag.

Note that NSNetService does not currently support queue-based scheduling 
<rdar://problem/20584529>.  Despite that, I'd still go with option B.  Doing 
your own listening socket is not fun in the general case, and it's much easier 
to let the system take care of this for you.

Share and Enjoy
--
Quinn "The Eskimo!"                    <http://www.apple.com/developer/>
Apple Developer Relations, Developer Technical Support, Core OS/Hardware



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/macnetworkprog/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to