java - Android tcp socket set etimedout value -
I have a TCP socket client on Android, besides I have a TCP socket server on NodeJS, which every 2 seconds customer tests Sends a message when I launch the application, then it receives a test message from the server. But when I close the Wi-Fi connection, my client socket closes SocketException (etimedout) and throws, and if I switch to Wi-Fi, then I can not get a server message. But server messages are already queued in the server and are waiting to send to the customer.
As I know, if TCP loses connection to the customer, then he should try to repair the connection and receive the server message. But in my case, clients can not retrieve messages, because the socket is closed.
With Windows and Linux Socket client on my PC, I am doing the same thing, but when I turn off Wi-Fi, Client socket does not stop, and when I turn on Wi-Fi I got the message, who sent it, when Wi-Fi is disabled
Question: Why in Android, it stops at the time of the socket? Can I set a deadline for the socket client to shut down?
I tried:
setKeepAlive (true); SetSoTimeout (10000);
Tried using SocketFactory.getDefault (). CreateSocket ();
No effect.
But when I turn off Wi-Fi connection, my customer socket stops And SocketException throws
Your socket is not locked When the WiFi switch is off, there are problems with socket inputstream, it gives 1, but the socket is alive.
Comments
Post a Comment