I'm still relatively new to sockets, and I haven't seen any information regarding this subject.
To write to a connected socket, you can either use
socket.getOutputStream().write
Or create a new DataOutputStream
from the socket OutputStream
and write to that.
DataOutputStream
makes sure the data is formatted in a platform independent way. This is the big benefit. It makes sure the party on the other side will be able to read it. There is no significant performance difference between both.
You should use OutputStream
only if you transfer raw binary data.