public virtual void Dispose(bool disposing)
 {
     if (!this.disposed)
     {
         if (disposing)
         {
             if (clientSocket != null)
             {
                 clientSocket.Close();
                 clientSocket = null;
             }
             if (serverSocket != null)
             {
                 serverSocket.Stop();
                 serverSocket = null;
             }
             if (DTOHandler != null)
             {
                 DTOHandler.Dispose();
                 DTOHandler = null;
             }
             if (curSwitcher != null && curSwitcher.IsAlive)
             {
                 curSwitcher.Abort();
                 curSwitcher = null;
             }
             if (serverRunner != null && serverRunner.IsAlive)
             {
                 serverRunner.Abort();
                 serverRunner = null;
             }
         }
     }
     this.disposed = true;
 }
 // Entry point for GUI or other calling class:
 public void MakeConnection()
 {
     if (this.hostOrClient)
     {
         this.serverSocket.Start();
         try
         {
             while (!serverSocket.Pending())
             {
                 Thread.Sleep(500);
             }
             this.clientSocket    = serverSocket.AcceptTcpClient();
             this.clientIP        = clientSocket.Client.RemoteEndPoint.ToString();
             this.connEstablished = true;
         }
         catch (NullReferenceException) { this.connEstablished = false; }
     }
     else
     {
         // Creating a ClientSocket also connects to the specified IP. clientSocket.Connect()
         try { this.clientSocket = new TcpClient(clientIP, 6656); this.connEstablished = true; }
         catch { this.connEstablished = false; }
         NativeMethods.SetCursorPos((int)screenCenter.X, (int)screenCenter.Y);
     }
     if (this.connEstablished)
     {
         this.DTOHandler = new DTOHandlerImpl(
             new BinaryReader(clientSocket.GetStream()),
             new BinaryWriter(clientSocket.GetStream()));
     }
 }