The cilent (emulator of android studio) makes a post request to a remote server (port:80, built by Flask in centos7). The connection was built successfully, and the server began to transmit a lot of packets to the cilent.
At first, everything seemed to go well: the cilent has received many normal packets and read infomation from them. But suddently, the server sent a packet flagged with [RST,ACK], and the cilent got an erro "java.net.SocketException: Connection reset".
(screenshot: https://imgur.com/6l7PQ8Z) (download the pcapng: https://easyupload.io/vophjy, password:wireshark) (the server is 118.89.144.241:80 by the way)
My code in Android Studio is like this:
..........
InputStream in=connection.getInputStream();
StringBuilder strbd =new StringBuilder();
byte[] bbuf=new byte[1024];
while(in.read(bbuf)>0){
strbd.append(new String(bbuf,0,in.read(bbuf)).trim());
}
} catch (IOException e) {
e.printStackTrace();
Log.d("ppppx", String.valueOf(strbd.length()));
}
............
PS: the outcome of strbd.length will change, sometimes it was 7784, and sometimes it was 9187, 10079, etc...
I have tried everything I can to find the reason, but failed, due to my limited knowledge in TCP/IP protocol. I will be really grateful if you can give me an enlightenment, thanks!