简体   繁体   中英

How to turn TCP Keepalive off?

I have a java application acting aa server and an android phone acting as a client. They are communicating over TCP sockets.

I often have the client sleep and when its buffer fills I want the wifi radio to be able to go to sleep. The problem is the client isn't sleeping. I noticed wireshark says my server is sending the a TCP KeepAlive packet approximately every half second so the wifi can't sleep. I've tried the following on the server and client.

connectionSocket.setKeepAlive(false);

But this appears to change nothing. I am using wireshark to analyze the traffic. Here is a screen shot of wireshark... the black lines indicate where my client is asleep and it's receieve buffer is full. Can I stop the keepAlive packets from being sent by the server?

Thanks!

TCP connections stay open until closed, the keep alive mechanism is here to detect connection failures.

Check out this link: Does a TCP socket connection have a "keep alive"?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM