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

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

  •  19-10-2022
  •  | 
  •  

Pergunta

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.

Nenhuma solução correta

Outras dicas

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

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top