Пример #1
0
        // connection
        private void handleClientConnection(object obj)
        {
            TcpClient client = obj as TcpClient;

            this.stream = new SslStream(client.GetStream(), false);

            try
            {
                this.stream.AuthenticateAsServer(this.server.certificate, false, SslProtocols.Tls, true);

                SSLHelper.DisplaySecurityLevel(this.stream);
                SSLHelper.DisplaySecurityServices(this.stream);
                SSLHelper.DisplayCertificateInformation(this.stream);
                SSLHelper.DisplayStreamProperties(this.stream);

                this.stream.ReadTimeout  = Config.connectionTimeout;
                this.stream.WriteTimeout = Config.connectionTimeout;

                while (true)
                {
                    this.server.receiveRequest(this, TCPHelper.read(this.stream));

                    Thread.Sleep(10);
                }
            }
            catch (Exception e)
            {
                ExceptionHelper.print(e);
            }
            finally
            {
                this.stream.Close();
                client.Close();
            }
        }
Пример #2
0
        private void readRequest()
        {
            try
            {
                while (true)
                {
                    this.receiveRequest(TCPHelper.read(this.stream));

                    Thread.Sleep(10);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Message Receiver crasched : {0}", e.ToString());
                this.stream = null;
                this.thread = null;
            }
        }