コード例 #1
0
 public void Conect(string host, int port)
 {
     if (mStaus != PEER_STATUS.NONE)
     {
         return;
     }
     Close();
     mClient = new TcpClient(famliy);
     mStaus  = PEER_STATUS.CONNECTING;
     mClient.BeginConnect(host, port, onBeginConnect, null);
 }
コード例 #2
0
 void Close()
 {
     if (null != mClient)
     {
         mClient.Close();
     }
     mClient = null;
     mStaus  = PEER_STATUS.NONE;
     mSendBuff.Clear();
     mSendAsy    = null;
     mRecieveAsy = null;
     mRecieveStream.Close();
 }
コード例 #3
0
 void onBeginConnect(IAsyncResult ar)
 {
     if (null != mClient)
     {
         mClient.EndConnect(ar);
         if (null != mOnConnect)
         {
             mOnConnect(mClient.Connected);
         }
         if (!mClient.Connected)
         {
             Close();
         }
         else
         {
             mRecieveStream = new MemoryStream();
             mStaus         = PEER_STATUS.CONNECTED;
         }
     }
 }
コード例 #4
0
 public void Conect(string host, int port)
 {
     if (mStaus != PEER_STATUS.NONE)
     {
         return;
     }
     Close();
     mClient = new TcpClient(famliy);
     mStaus  = PEER_STATUS.CONNECTING;
     try
     {
         mClient.BeginConnect(host, port, onBeginConnect, null);
     }
     catch (System.Exception e)
     {
         Close();
         if (null != mOnConnect)
         {
             mOnConnect(false);
         }
     }
 }