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