OutputStream out = socket.getOutputStream();
out.write(someData);
socket.close();
Will socket.close()
cause the peer socket not to receive someData
?
OutputStream out = socket.getOutputStream();
out.write(someData);
socket.close();
Will socket.close()
cause the peer socket not to receive someData
?
Will
socket.close()
cause the peer socket not to receive someData?
Definitely not, in this case. It will enqueue a FIN, which can only be received by the peer as end of stream after receiving all pending data.
However as a general rule you should call out.close()
, to ensure any data buffered in out
gets flushed, in case out
was a buffered stream, rather than socket.close()
, which doesn't care about whatever buffered streams may have been wrapped around its output stream.