title: closing sockets in asynchronous sockets
body: <p>I have developed server listening to multiple clients using asynchronous sockets. I have used the following method for stopping server from listening to clients.</p>
  
  <pre><code>   //Button 2 -- To Stop Server
      private void button2_Click(object sender, EventArgs e)
      {
          socket.Shutdown(SocketShutdown.Both);
          socket.Disconnect(false);
          socket.Close();
          socket.Dispose();
       }
  </code></pre>
  
  <p>But problem is that when I restart the server it shows error socket connection in use. So what is the proper way for closing sockets ans stopping server. I need to stop the server as soon as I press button in UI.</p>