I am currently developing an iOS app which uses CFStream to communicate with a C# server. Sending 1 TCP packet over this connection does what its supposed to. However, if I try to send two packets, they both fail.
The server is designed to be asynchronous like the one here. The iOS side is designed using the CFStream classes, as dictated in this tutorial.
Why does this occur and how can I fix it? All help is greatly appreciated!
EDIT: I have just tried replacing the C# server with a Python server, and the system worked flawlessly, which would hint that the problem is server-side. Maybe the server is accidentally closing the connection after receiving the first packet?
It turns out the server was set up to close the connection after it sent its first packet of information to the client. The solution was to add a
in the ReadCallback() method, to ensure it would resume listening to the client after processing its request.