Can I manually pack byte arrays and send them in one call to write help?
Yes, send them all at once to write. This will maximize the likelihood that your bytes will be sent in one packet.
Of course, you will never know, since there are too many variables - different OSs and many different network devices between you and your colleague, but if you give the OS the opportunity to put everything together, you will usually try to.
If you disable nagle and make separate system calls (remember, the OS manages sockets, not your application or java), you ask the OS to send them separately. The OS has no idea that you are going to rewrite the record again with some data.
source share