예제 #1
0
 public void Start(Socket ClientSocket)
 {
     if (ClientSocket == null || !ClientSocket.Connected)
     {
         return;
     }
     _ChannelIsClosed = false;
     _ChannelSocket   = ClientSocket;
     SetKeepAlive(_Settings.HeartBeatPeriod);
     if (_UseSSL)
     {
         if (_AsSslClient)
         {
             _StreamSSL.AuthenticateAsClient(_ChannelSocket, _SslProtocol);
         }
         else
         {
             _StreamSSL.AuthenticateAsServer(_ChannelSocket, _Certificate);
         }
     }
     StartReceive();
 }
예제 #2
0
        public bool Start()
        {
            Listener.Start();
            client = Listener.AcceptSocket();
            if (!_StreamSSL.AuthenticateAsServer(client, X509Cert))
            {
                return(false);
            }
            byte[] buffer = new byte[4096];
            do
            {
                int bytes = client.Receive(buffer, 0, buffer.Length, SocketFlags.None);
                if (bytes <= 0)
                {
                    break;
                }
                if (!_StreamSSL.Decrypt(buffer, 0, bytes))
                {
                    break;
                }
            }while (true);

            return(false);
        }