简体   繁体   中英

Idle time out exception in Server Client socket

I am working on a server client project where server is a Gateway which resides in the field and where we are developing the client. The client is scheduled to connect the server and get the data. Now my problem is the server has idle timeout for 10 secs. If the server and client are idle for 10 secs the server disconnects the client automatically. How can I catch the timeout exception in client where there is no chance of server sending any message to client as time out occurred so it is closing the connection.

if the server closes the client connection due to some network failure the client gets Connection refused exception. Similarly I want for idle timeout connection. Please help me in solving this issue. Thanks in advance.

If the server closes the client connection due to some network failure the client gets Connection refused exception.

No it doesn't. You get that if the server closes the listening socket and you try to make a new connection.

The client will get an EOS indication on read, or an IOException: "connection reset" on write.

That's the only way you can know.

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