How can I use buffered I/O Object streams over a socket and guarantee
transmission even when the packet object is smaller than the buffer
size? I want the efficiency benefits of buffered streams when
sending large packets, but I need to force small packets through
You must use the flush() method to force all data buffered in a BufferedOutputStream to be written to the underlying output stream. If you have wrapped a socket with a BufferedOutputStream, this will force all the buffered data to be sent over the socket.