Exemplo n.º 1
0
        private void AcceptSocket()
        {
            IO.AcceptSocket(this.listener, (exception, socket) =>
            {
                if (exception != null)
                {
                    if (this.OnError != null)
                    {
                        this.OnError(exception);
                    }

                    return;
                }

                if (this.OnSocket != null)
                {
                    var networkstream = new NetworkStream(socket, false);

                    var sslstream = new SslStream(networkstream);

                    IO.AuthenticateAsServer(sslstream, certificate, (exception1) =>
                    {
                        if (exception1 != null)
                        {
                            if (this.OnError != null)
                            {
                                this.OnError(exception1);
                            }

                            return;
                        }

                        this.OnSocket(new Socket(socket, sslstream));
                    });
                }

                this.AcceptSocket();
            });
        }