I am writing files / large amount of bytes over socket.
But lets say I am writing bytes. I do this;
//Connection.data is a dataoutputstream
byte[] a = new byte[filelength];
//load file into the array
//write file
for (int i = 0; i < a.length; i++) {
Connection.data.writeByte(a[i]);
}
To receive:
//dat is a datainputstream
byte[] byteA = new byte[bytestoread]
for (int i = 0; i < toread; i++) {
byteA[i] = dat.readByte();
}
I do log the incoming data, and lets say if the file is 200000 bytes, it stops at around 199990 bytes etc. Basically, any size of the byte[], and it will stop at the last bytes, and time out. I will explain more if you dont understand. Thanks.