java.net.SocketException: Connection reset

前端 未结 10 1512
慢半拍i
慢半拍i 2020-11-22 03:02

I am getting the following error trying to read from a socket. I\'m doing a readInt() on that InputStream, and I am getting this error. Perusing th

10条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-22 03:53

    Embarrassing to say it, but when I had this problem, it was simply a mistake that I was closing the connection before I read all the data. In cases with small strings being returned, it worked, but that was probably due to the whole response was buffered, before I closed it.

    In cases of longer amounts of text being returned, the exception was thrown, since more then a buffer was coming back.

    You might check for this oversight. Remember opening a URL is like a file, be sure to close it (release the connection) once it has been fully read.

提交回复
热议问题