C# Do I Need Socket.Close()?

asynchronous, c#, sockets

Solution

Most authors seem to agree that if something implements IDisposable, you should call Dispose. The easiest way to do this is to use 'using' which automatically calls Dispose for you.

using (DirectoryEntry de = new DirectoryEntry(path))
{
.... some code
}

Problem

I am studying asynchronous C# Sockets at the moment and i have noticed something that i am confused about. In all the End...(Accept/Connect) etc there is a code section like: ``` Socket s = (Socket) ar.AsyncState; ``` Here it is being casted as a socket. As each End uses these local Sockets is there any point in trying to `close()` any of them once I am done? What is the best practice?

Original source