I'm trying to set up two-way communication between a server application and an iPhone application. What I've used is a CFSocket coupled to a CFReadStream which is itself scheduled with a run loop (or so it should be).
Thus I expect to have my callback function called for every event that I've registered for. But the only event I get is the "open completed" event, I don't even get an "end encountered" event when I close the socket.
WireShark shows the connection being established in a proper fashion. Data is also being PSH'ed and ACK'ed properly. The connection is FIN/ACK'ed properly when i kill the iPhone application. So everything looks fine. Netstat also shows an established connection, but netstat also shows the receive queue which i can see growing larger whenever i send data from the server to the iPhone application. However, no events are fired on the iPhone to signal that data is available.
I am clueless as to why I don't receive all events.
Here is the code (which is called from an UIViewController's viewDidLoad event):
[Objective C] CFSocket troubleshooting - Pastebin.com