Can someone explain the following behavior in Java sockets:
The general idea is this:
- Open socket, Obtain I/O streams.
- Write request, Close out stream
- Read Response, Close in stream
- Close socket.
Here's my question / issue.
If I use a
PrintWriter for output, and then close it, It closes the whole socket, and the subsequent read operation fails miserably.
Instead if I directly use the socket's
shutdownOutput() method, it correctly closes the output stream channel, while keeping the socket alive.
Why would closing the
PrintWriter object take the whole socket down with it?