• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: UDPEcho example and socket creation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: UDPEcho example and socket creation
      • From: Jeff Johnson <email@hidden>
References: 
 >UDPEcho example and socket creation (From: Rick Mann <email@hidden>)

  • Prev by Date: Re: kCFStreamPropertyFTPFileTransferOffset and Resuming FTP uploads
  • Next by Date: Re: kCFStreamPropertyFTPFileTransferOffset and Resuming FTP uploads
  • Previous by thread: UDPEcho example and socket creation
  • Next by thread: Re: UDPEcho example and socket creation
  • Index(es):
    • Date
    • Thread