コード例 #1
0
ファイル: SockTcp.cs プロジェクト: schifflee/bjd5
        //ACCEPT
        //Ver5.9.2 Java fix
        //public SockTcp(Kernel kernel, Socket s) : base(kernel){
        public SockTcp(Kernel kernel, Ssl ssl, Socket s) : base(kernel)
        {
            //************************************************
            //selector/channel生成
            //************************************************
            _socket = s;
            _ssl    = ssl;

            //既に接続を完了している
            if (_ssl != null)
            {
                //SSL通信の場合は、SSLのネゴシエーションが行われる
                _oneSsl = _ssl.CreateServerStream(_socket);
                if (_oneSsl == null)
                {
                    SetError("_ssl.CreateServerStream() faild");
                    return;
                }
            }

            //************************************************
            //ここまでくると接続が完了している
            //************************************************
            //Set(SockState.Connect, (InetSocketAddress) channel.socket().getLocalSocketAddress(), (InetSocketAddress) channel.socket().getRemoteSocketAddress());

            //************************************************
            //read待機
            //************************************************
            BeginReceive(); //接続完了処理(受信待機開始)
        }
コード例 #2
0
ファイル: SockTcp.cs プロジェクト: schifflee/bjd5
 //通常のサーバでは、このファンクションを外部で作成する
 private void CallbackConnect(IAsyncResult ar)
 {
     if (_socket.Connected)
     {
         _socket.EndConnect(ar);
         //ここまでくると接続が完了している
         if (_ssl != null)
         {
             //SSL通信の場合は、SSLのネゴシエーションが行われる
             _oneSsl = _ssl.CreateClientStream(_socket);
             if (_oneSsl == null)
             {
                 SetError("_ssl.CreateClientStream() faild");
                 return;
             }
         }
         BeginReceive(); //接続完了処理(受信待機開始)
     }
     else
     {
         SetError("CallbackConnect() faild");
     }
 }