Maybe I'm being dumb here, but with RAII in C++ at least, doesn't shutdown() and then close() have to be called on the socket by the programmer explicitly in the destructor for the class?
> doesn't shutdown() and then close() have to be called on the socket by the programmer explicitly in the destructor for the class?
yes, the class has to be written only once - and I have personnally never had to write it except in that one group project in school, since I use libraries that handle it - e.g. boost.asio or Qt Network.
If you are in C, even if you use an abstraction layer, you have to remember to call a _free / _destroy-like function every time you write some code that uses sockets.
Point being, the same is not true for virtual memory.
You could leave the memory deallocation out of the destructors, and it is all going to be returned to the OS instantly on _exit().