Pregunta

My question is , I have create a TCP connection , and when it stays without transfering any data about 1 hour, It already disconnected from the server, but it do not notify me , that it's disconnected, Should I send keep alive packets to the server ? or should i send keep alive packets from server to client ? Or should i send to both ?

¿Fue útil?

Solución

Yes you should. A few days ago I created a TCP socket/server application, and I got the same problem. I fixed it by starting to send keep alive packets.

If you send keep alive packets, your problem will disappear.

I've heard some people say that the OS will send keep alive packets for you, I am not very familiar with this, but sending keep alive packets explicitly worked for me

Otros consejos

it do not notify me that it's disconnected

It can't. There is no means whereby it could do so other than inducing an EOS or a 'connection reset' next time you try an I/O.

Should I send keepalive packets ...

If you have this problem, yes. In general, probably not.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top