title: Only one usage of each socket address (protocol/network address/port) is normally permitted?
body: <p>I've been looking for a serious solution on google and I only get &quot;Registry solutions&quot; kind of stuff which I don't think even relate to my problem.</p>
  <p>For some reason I get this Error, while I'm only starting the <code>TcpListner</code> once, and when and if it fails, I stop the server.</p>
  <p>Here is my code:</p>
  <pre><code>class Program
      {
          private static string ServerName = &quot;&quot;;
          private static string UserName = &quot;&quot;;
          private static string Password = &quot;&quot;;
          private static string dbConnectionSring = &quot;&quot;;
          private static X509Certificate adminCertificate;
          private  static byte[] readBuffer = new byte[4096];
          static void Main(string[] args)
          {
              Console.WriteLine(&quot;Please grant SQL Server access to the Admin Server:\n&quot;);
              Console.Write(&quot;Server Name: &quot;);
              ServerName = Console.ReadLine();
              Console.Write(&quot;\nUser Name: &quot;);
              UserName = Console.ReadLine();
              Console.Write(&quot;\nPassword: &quot;);
              Password = PasswordMasker.Mask(Password);
              dbConnectionSring = SQLServerAccess.CreateConnection(ServerName, UserName, Password);
              adminCertificate = Certificate.GenerateOrImportCertificate(&quot;AdminCert.pfx&quot;, &quot;randomPassword&quot;);
              try
              {
                  Console.WriteLine(&quot;Initializing server on the WildCard address on port 443...&quot;);
                  TcpListener listener = new TcpListener(IPAddress.Any, 443);
                  try
                  {
                      Console.WriteLine(&quot;Starting to listen at {0}: 443...&quot;, IPAddress.Any);
                      
                      //the backlog is set to the maximum integer value, but the underlying network stack will reset this value to its internal maximum value
                      listener.Start(int.MaxValue);
                      Console.WriteLine(&quot;Listening... Waiting for a client to connect...&quot;);
                      int ConnectionCount = 0;
  
                      while (true)
                      {
                          try
                          {
  
                              listener.BeginAcceptTcpClient(new AsyncCallback(AcceptCallback), listener);
                              ConnectionCount++;
                              Console.WriteLine(
                                  &quot; Accepted connection #&quot; + ConnectionCount.ToString());
  
  
                          }
                          catch (SocketException err)
                          {
                              Console.WriteLine(&quot;Accept failed: {0}&quot;, err.Message);
                          }
                      }
                  }
                  catch (Exception ex)
                  {
                      Console.WriteLine(&quot;Listening failed to start.&quot;);
                      listener.Stop();
                      
                      Console.WriteLine(ex.Message);
                  }
              }
              catch (Exception ex)
              {
                  Console.WriteLine(&quot;Initialiazing server Failed.&quot;);
                  Console.WriteLine(ex.Message);
              }
          }
  </code></pre>