The normal way to get decent performance from a socket (for int read()
and write(int)
) is to use a buffered stream / reader / writer. That reduces the number of system calls and makes byte or character at a time I/O much faster.
I don't expect that using NIO will make a significant difference. If the problem is not buffering, then (IMO) it is probably a network bandwidth and/or latency issue. If that is the case, there is little that you can do in Java that would make much difference.