TCP WriteObject Timeout is 16 minutes, wow

时间:2018-12-19 11:38:00

标签: android tcp tcpclient

I have an app where several client tablets send images to the server tablet on TCP. Have been in the final stage of testing and everything seemed to work fine until I tried out of what happens if I disconnect from the wifi with the server tablet.

The clients still try to send the image which is due to the TCP client side has no idea of the connection died on the server side. No problem.

So I have an outputsteam object (os2) that sits here:

os2.writeObject(messagebody);

for 16(!!!) minutes before it times out.

Have done some searching and found this on stackoverflow: ObjectOutputStream IOException / timeout on Android

You can't. TCP doesn't tell you. It doesn't know. It is busy doing buffering and retrying. It will wventually time out, and if you do a write after that you will get the exception. There is no control whatsoever over how long that takes.

Is this what I think it is? This 16 minutes I've got just got to be accepted and there isnt anything I can do about? Is there any parameter which can be used to set the timeout of the writeobject less? Or any programming technique that is used for these cases?

0 个答案:

没有答案