views:

282

answers:

3

Hi all,

I have a TCP server running on a machine. (implemented in Java). I need to connect to that server from a iPhone and send data to the server and also, receive data on the iphone when server pushes me data. So I need to be notified when data pushes from the server.

Is there a way to do this in Objective C(socket programming). Although I googled I couldn't find a solution. But I saw CFSocket etc. Please anyone have a solution?

A: 

You can use the CFNetwork family of classes to implement lower level sockets. Apple has an introduction document that describes the use of these classes.

Claus Broch
A: 

CFSocket calls and similar will let you create sockets. You can then use CFStreamCreatePairWithSocket() to create a CFReadStreamRef and CFWriteStreamRef, which you can cast to NSInputStream* and NSOutputStream*.

tc.
+1  A: 

Hi all, after a possible solutions in the internet, I found a nice asynchronous TCP and UDP socket Library here. (http://code.google.com/p/cocoaasyncsocket). This library worked really well for me so far. This wraps the CFSocket and CFStream.

Thanks for your replies.

charith