I need to connect to a server via TCPIP. I found out how to do this, but the examples do not make a permanent connection, it just connects sends data and drops the connection. I need to leave the connection open to pass back and forth several packages.
For example I am used to requesting a connection, then having a process to listen for incoming data. Like this:
- Connect
- Acknowledge connection
- Send data
- Receive data … go back to #3
- Close the connection.
Is there anything that I can read on this or better yet sample code?
I made a similar application with a different use, only there was no listening involved on the server side, only sending. However, it does stay open in a loop, and you could modify it to, upon receiving a specific message, close the loop and the connection using the strstr command in the while loop. See this topic: Garbage data transmitted in WiFi TCP connection from desktop to Android for the code, and change the line:
to
in order to fix the issue I was having.