Oh, I feel like a n00b sometimes. (I sense a few people nodding understandably...)
The following
optimisation deathtrap caused my TCP streams to ditch all outbound-pending-bytes.
1 2 3 4 5 6 7 8 9 10 11 12 13
| this.socket.setKeepAlive(false); this.socket.setSoLinger(true, 0); this.socket.setReuseAddress(true); this.socket.setTcpNoDelay(true);
for(...) { this.out.write(...); this.out.flush(); } this.out.close(); |
Appearantly
flush() flushes the bytes into the OS buffer, instead of flushing the OS buffer itself. Causing
setSoLinger(true, 0) to discard any pending bytes and immediately closing the stream. Oh the fun I had this morning...