示例#1
0
 private void ListenForMessages()
 {
     while (m_listenerActive)
     {
         // receive messages
         SecureTcpClient client = null;
         try {
             client = m_listener.AcceptTcpClient();
             if (client != null)   // everything ok
             // disable Nagle algorithm, to reduce delay
             {
                 client.NoDelay = true;
                 // now process the message of this client
                 SslServerTransport transport = new SslServerTransport(client);
                 m_clientAcceptCallback(transport);
             }
             else
             {
                 Trace.WriteLine("acceptTcpClient hasn't worked");
             }
         } catch (Exception e) {
             Debug.WriteLine("Exception in server listener thread: " + e);
             if (client != null)
             {
                 client.Close();
             }
         }
     }
 }
示例#2
0
 private void ListenForMessages() {
     while (m_listenerActive) {
         // receive messages
         SecureTcpClient client = null;
         try {
             client = m_listener.AcceptTcpClient();
             if (client != null) { // everything ok
                 // disable Nagle algorithm, to reduce delay
                 client.NoDelay = true;
                 // now process the message of this client
                 SslServerTransport transport = new SslServerTransport(client);
                 m_clientAcceptCallback(transport);
             } else {
                 Trace.WriteLine("acceptTcpClient hasn't worked");
             }
         } catch (Exception e) {
             Debug.WriteLine("Exception in server listener thread: " + e);
             if (client != null)  {
                 client.Close();
             }
         }
     }
 }