close

Closes this connection gracefully.
This method will attempt to flush the internal output
buffer prior to closing the underlying socket.
This method MUST NOT be called from a different thread to force
shutdown of the connection. Use shutdown instead.

isStale

Checks whether this connection has gone down.
Network connections may get closed during some time of inactivity
for several reasons. The next time a read is attempted on such a
connection it will throw an IOException.
This method tries to alleviate this inconvenience by trying to
find out if a connection is still usable. Implementations may do
that by attempting a read with a very small timeout. Thus this
method may block for a small amount of time before returning a result.
It is therefore an expensive operation.