Re: Which API should I use for sockets
Re: Which API should I use for sockets
- Subject: Re: Which API should I use for sockets
- From: Becky Willrich <email@hidden>
- Date: Fri, 13 Jun 2003 12:34:26 -0700
Take a look at /Developer/Examples/Networking/Echo and
/Developer/Examples/Networking/Echo Client. These use a combination of
CFSocket and CFSocketStreams (which just provide a stream API over the
top of CFSocket).
REW
On Friday, June 13, 2003, at 11:43 AM, Kirk Haderlie wrote:
Thanks for the quick feedback!
Does anyone know of sample code which demonstrates CFSockets? I
looked in
the networking sample code and it all looked like OpenTransport
samples.
----------
From: Scott Thompson
Sent: Friday, June 13, 2003 11:07 AM
To: email@hidden
Cc: Kirk Haderlie
Subject: Re: Which API should I use for sockets
I am beginning a new project that will use TCP sockets. I am new to
OS X
development and would like some opinions on which API we should use.
(CFSockets, NSSockets, or BSD Sockets) If there is any documentation
on
Apple's Site that answers this question please direct me there.
Well... it depends...
BSD Sockets would be the "raw API". It would be most appropriate if
you needed absolute and exacting control over the socket behavior and
life cycle. Correspondingly it would be the lowest overhead in terms
of execution, but probably the highest overhead in terms of learning
(if you don't already know how Sockets work).
Both CFSocket and NSSocketPort are built on top of the "raw" BSD
sockets. As such, you will have to know a bit about the BSD sockets
to
use them, but not as much as if you were coding to the BSD layer
directly. Both of these provide a level of insulation from you as the
engineer in terms of making it easy to set up and deal with a socket.
However, both provide a bit of overhead for their own internal stuff
so
they probably would not be as high-performance as coding to the BSD
layer. Having said that, I have found for my work that CFSocket (in
particular) is plenty fast enough... but depending on what you're
trying to do you may find otherwise.
In selecting between CFSocket and NSSocketPort... it would depend
largely on which API your more comfortable with and what API is used
throughout the rest of your application. If you are writing an
application to the Carbon API set then CFSocket is going to fit into
your code more naturally. If, in contrast, you are using Cocoa,
NSSocketPort will probably not be out-of-place.
The other option would be if you are writing a Java application. In
that case, of course, you might consider using the Java native library
support for sockets.
It's a difficult question to answer more fully without some idea of
what your application wants to do with Sockets, and how the
application
itself is to be written.
Scott
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.