views:

114

answers:

1

Hi,

I am creating server-client application for iPhone. I want to communicate between two application in same network.

For this functionality i am planning to use sockets. How much efficient BSD sockets to use with iphone??

Is there any option available to implement same functionality?

Thanks,
Jim.

+1  A: 

See this thread on the iPhone Dev SDK website.

The CF networking stuff is a bit confusing and hard to wrap your head around. But, it's just a set of functions that use BSD sockets and integrate them with the run loop so you don't have to create threads. You can still use BSD sockets yourself

Basically, the thread points out multiple libraries / frameworks which integrate well with the iPhone environment, and using any of them instead of straight BSD sockets probably won't make any significant performance difference. Unless you're really comfortable with low level socket programming you're probably better of with one of the libraries.

Don't do premature optimization - use whatever socket interface you are most comfortable with and which will help you get the job done quickly and produce clear, maintainable code.

EDIT

In response to Jim's question below:

Yes. There are a few factors that determine the system wide and per process socket limits. Take a look at this article for a discussion of these issues. iPhone and Linux are both Unix based OS's so they probably share some of these system admin related socket limitations, but you'll have to look up the system specific admin details.

Second, there are limits imposed by the architecture of UDP and TCP. Basically, UDP and TCP are both limited to 2^16 listening sockets per machine IP address since a listening socket is defined by a fixed 32 bit IP address and a 16 bit Port number. However, since a connected socket is defined by the set of [ [src IP] [src Port] [dst IP] [dst Port] ] then the number of connected sockets you can theoretically have on a single machine IP is significantly higher, something like 2^64 although practically your OS would probably barf way before you hit that limit.

Robert S. Barnes
Thanks for your inputs.One more question at this point is there any limitation of number of connections while using sockets?
Jim
@Jim: My answer is too long for a comment, so I added it as an edit to my answer, see above.
Robert S. Barnes
Thanks Roberts, that's make sense.
Jim