views:

250

answers:

2

I want to create a iPhone chat application and i do not have any experience of socket programming so can u please help me understand How can i do long polling from iPhone application?

Also can NSURLConnection be used for this purpose or we need to use some low level API?

Are there any libraries available for the same?

+2  A: 

Check out CocoaAsyncSocket.

Shaggy Frog
@shaggy thanks ...i already did that but is there any other way of doing it also or is it the only library for this.
Hitesh Manchanda
CocoaAsyncSocket uses the low-level CFStream framework to do its business. You can always reimplement what they did using CFStream yourself, or even use CFSocket if you really want to. Or you could go all the way down to BSD sockets. But if you are doing socket programming, in Cocoa, for the iPhone, you should start with CocoaAsyncSocket.
Shaggy Frog
+1  A: 

Long polling is for languages like javascript that cannot open persistent connections. You can still do long polling with something like NSURLConnection, but you would be much better served by CFStreamCreatePairWithSocketToHost or similar to open a full bidirectional socket.

Long polling is basically a hack that has become a buzzword.

drawnonward
thanks for the clarification.....But what do u think should be the approach to make a chat application in general.That would be of real help to make progress in that direction for me.
Hitesh Manchanda
Chat is really more about the server than the client. If you pick a standard chat server like jabber, there is probably an open source client implementation for iPhone. I have not used any, so I would follow the advice from Shaggy or google the specific chat protocol you are using.
drawnonward