Re: UDPEcho example and socket creation
Re: UDPEcho example and socket creation
- Subject: Re: UDPEcho example and socket creation
- From: "Quinn \"The Eskimo!\"" <email@hidden>
- Date: Fri, 22 Oct 2010 10:47:54 +0100
On 22 Oct 2010, at 06:56, Rick Mann wrote:
> Hi. I'm looking at the UDPEcho example, and I'm curious. When it comes time to actually create the socket, it uses primarily BSD calls before calling CFSocketCreateWithNative(), rather than creating a CFSocket from the start. Is there any reason to do that over the alternative?
Both approaches are valid. I prefer to use BSD directly because:
o I find the BSD calls easier to understand -- In my experience the documentation for calls like CFSocketSetAddress is rather poor.
o it gives you more direct control -- For example, CFSocketSetAddress is equivalent to bind() + listen(), which is a problem if you want to bind on /outgoing/ TCP socket (to force it to run over a particular interface) or you want to bind a UDP socket (where calling listen() makes no sense).
o they give you better access to errors
The value of CFSocket, IMO, is the run loop integration. Everything else is just noise.
Despite all of the above, if the CFSocket calls work for you, there's nothing wrong with using them.
S+E
--
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@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden