Should I still call Dispose() on my socket after closing it?
For example:
mySocket.Shutdown(SocketShutdown.Both);
mySocket.Close();
mySocket.Dispose(); // Redundant?
I was wondering because the MSDN documentation says the following:
Closes the Socket connection and releases all associated resources.
Calling Close internally calls Dispose so you don’t need to call both. From .NET Reflector:
If possible you should use the
usingpattern so that you always call Dispose regardless of any exceptions that might occur.