Home > Mobile >  Android long TCP connection, the client and the server data, abnormal disconnecting the report?
Android long TCP connection, the client and the server data, abnormal disconnecting the report?

Time:09-26

I wrote a simple is to use the android socket TCP connection,

Send data using code is as follows:
MOutputStream=mClientSocket. GetOutputStream ();
MOutputStream. Write (buffer);
MOutputStream. Flush ();

Is the client and server code by getting into the Socket, get the byte stream, and then write data directly by flow,

Assumptions, now the client and server socket TCP has been established successfully, and the normal communication;

I take the initiative to close the client or server, the other party can be sensed, abnormal, and so on, there is no problem;

However,

If I unplug your network cable, only to find that both sides don't know, the client can normal to send data to the server; The server can be normal to send data to the client, just don't get each other,

I pull the cable about 20 minutes, during text data, there has been no error, I was very surprised,

TCP connection is not reliable, disconnecting all don't know, is this why?

CodePudding user response:

Long broken links are manually request each other, suddenly pull cable is unable to perceive, can try to test the heartbeat or set the timeout value
  • Related