Hello,
My server can handle multiple clients using TCP sockets.
A worker thread listens and accepts new connections then add it to array
SOCKET clientsocket[100]
Problem I am facing is that if there are few minutes of inactivity with specific client I cannot connect with it (Client program keeps waiting to recv() data as its in blocking mode) but the data sent by server never gets to client.
I have read that usually such timeout is 2 hours, I have also read about Keep alive parameter but how is it possible that my connection closes after few minutes of inactivity?
I am adding to array so I can process any selected client. For example if 3 clients are added and I want to access 2nd I can send data to clientsocket[1]..
I have seen similar implementation on various forums hope there is nothing wrong with it.
Thanks for responding
If you think something is timing out the connection, then that's one way to deal with it. However, you really only need that stuff with UDP connections, TCP has all that stuff built in (that's kinda the point of TCP), so there's something somewhere killing the connection if you're getting that with TCP.
Server is built on visual studio c++ MFC, something is definitely killing the connection. Could it be because of the VPN I use? because when I connect to clients locally (this issue does not appear).
What is a good way to find out?
Thanks
It won't be the VPN itself, VPNs a designed to be reliable. But "Ops" love to kill things, long running processes, long connections, ... Typically, they don't want anything abusing their lovely systems.
Cool thanks for the help.
I tested using various connections, and seems like its the operating system after all trying to save resources and cutting idle connections.
To keep connections alive, just send a heart beat ;)