How to prevent winsock application from disconnecting due to network inactivity (c++)

StackOverflow https://stackoverflow.com/questions/22162179

  •  19-10-2022
  •  | 
  •  

Currently have a winsock application that connects to a server. It can send and receive packets, but after a few minutes(around 2, if you wanted me to guess) of not sending anything, it disconnects and I have restart it, which is pretty annoying. Thanks in advance.

没有正确的解决方案

其他提示

You can try setting KEEPALIVE to true. You set this using the socket options. You have to set it on both the client socket and the server's listening socket.

Have a look at: http://linux.die.net/man/2/setsockopt And http://msdn.microsoft.com/en-us/library/windows/desktop/ms740476(v=vs.85).aspx

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top