Reputation: 355
I have a socket that's a member of a shared_ptr object. Do I have to explicitly call socket.close()
or is it safe to assume that it is closed automatically?
The reason I ask is because in this TCP Daytime Server Example the author doesn't explicitly call socket.close()
.
Upvotes: 1
Views: 73
Reputation: 393114
It depends on when you need the socket to be closed.
In general, the socket desctructor causes the socket to close (because not doing so would amount to a resource leak).
Upvotes: 1