It depends on his definition of "valid socket descriptor", doesn't it?
He didn't define that term, so we cannot say.
We have a saying in my language - "'n helder verstand het net 'n
halwe woord nodig". Dutch might help you translate
. But point
taken - this is a C++ language newsgroup. I've just look at draft 3035
and
I've noticed the words socket and descriptor (amongst header
system_error).
More on-topic, if he wants one particular, limited kind of robustness
he could write a small RAII wrapper class which can only contain
correctly opened sockets.
The word "RAII" does not exist in the standard. Care to
define it? Just kidding.
For the RAII wrapper to guarantee a valid descriptor,
it would have to open it during construction (otherwise
we have the same problem).
- Seeing that it is a RAII wrapper, I'm assuming it
will close it during destruction.
- Is it copyable?
- What happens to the descriptor during copying. Is
ownership transferred to the receiver?
- Are we going to make the socket descriptor public? Because
if we don't, it might be closed... How will we handle
failure to close in our RAII wrapper (during destruction)?
If we [do] write this RAII wrapper, why not give it some
functions as indication what the intent of this particular
descriptor is, seeing that this intent is not clear when
looking at type SOCKET or int...
The there exists the question of whether operations
will complete asynchronously or synchronously, and how
that relates to our RAII object... How would we expose
our descriptor (Listening for clients, connecting to servers,
and receiving having the potential of completing async).
etc...
Personally I find that with the right overall design, this is not a
problem. You can give some higher-level object ownership of the socket,
and let /it/ worry about validity.
Agreed.
Kind regards,
Werner