示例#1
0
 private void _acceptorloop()
 {
     while (this._active)
     {
         if (!_tcpListener.Pending())
         {
             Thread.Sleep(100); // choose a number (in milliseconds) that makes sense
             continue;          // skip to next iteration of loop
         }
         TcpClient clientSocket = default(TcpClient);
         clientSocket = _tcpListener.AcceptTcpClient();
         GSocket gs = new GSocket(clientSocket);
         if (ClientArrived != null)
         {
             ClientArrived(this, gs);
         }
     }
 }
示例#2
0
 public int Send(string data)
 {
     return(this.Send(GSocket.GetBytes(data)));
     //return this.Send(System.Text.Encoding.UTF8.GetBytes(data));
     //return this.Send(new System.Text.ASCIIEncoding().GetBytes(data));
 }