|
Boost : |
From: christopher baus (christopher_at_[hidden])
Date: 2006-01-12 16:53:25
> Is there any way to query a stream_socket for its connection state? Also
> when a connection is closed by a peer during a read operation what error
> should be expected?
>
> eof, not_connected, fault, operation_aborted all seem reasonable.
I should note that a tcp socket can have four connection states.
closed, open for read, open for write, open for read and write
It is often useful to know what state the socket is in before attempting
an operation. Once the state is determined by a low level operation
(open, send, recv, close, shutdown) the state can be stored with the
socket.
If this isn't stored in the stream_socket applications must carefully
parse the error codes, and store that state themselves.
I have found bugs code that didn't handle 1/2 connected sockets properly.
Unix nc (netcat) performs a write shutdown when it reads eof from stdin,
but leaves read open, so it is good for testing this.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk