Hello,

I am, for some reason only getting 64K of data back from my local host as I test my program for being able to write a text file to a server and back. The remaining of the data is all spaces instead of char's, so that the original and recieved files are the same size but the last amounts of data beyond 64K have turned to spaces instead of chars.

There is also a matter of a "java.net.SocketException: Software caused connection abort: socket write error" I don't know why this is saying this. Perhaps this problem and the above are related but I don't know how to fix it.

Any ideas would be greatly appreciated. The code and data files are attached.

Thanks,

Brian

Dani AI

Generated

reported a localhost file-transfer that stops behaving correctly around a 64 KB boundary and also hits a "socket write" failure; correctly pointed out this is an I/O/protocol bug rather than malware. Common, concrete causes are: using writeUTF (which is size-limited), not honoring the read(...) return value and writing a full buffer regardless of bytes actually read, or one peer closing the socket while the other is still writing.

Checklist and quick fixes:

  • Avoid DataOutputStream.writeUTF for large files; it is intended for short UTF strings. See the Java IO docs for DataOutputStream (DataOutputStream).
  • Always use the read return value and write only that many bytes. Example robust copy loop:
byte[] buf = new byte[8192];
int r;
while ((r = in.read(buf)) != -1) {
    out.write(buf, 0, r);
}
out.flush();
  • If message length is known, send a length prefix and use readFully/a loop to receive exactly that many bytes. If you need a clean EOF signal without closing the socket, use socket.shutdownOutput() then read until -1 (Socket).

Extra debugging tips: reproduce with a very small file first, log both sides (server/client) to see which side closes the stream, and capture the TCP flow with a packet trace. A write error like "Software caused connection abort" usually means the peer closed or reset the connection while the local side attempted to write; check server-side code for premature closes and the socket error handling (SocketException).

Recommended Answers

All 2 Replies

Any one have any ideas?

Thanks,

Brian

Doesn't look to be a malware problem, so why not post this in the correct forum?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.