Ejemplo n.º 1
0
 private void InitNet()
 {
     try
     {
         InitAsyncTimer();
         ip = m_Config.IP;
         port = m_Config.Port;
         if (this.asyncClient != null)
         {
             this.asyncClient.Dispose();
             this.asyncClient.onConnected -= new AsyncClient.Connected(client_onConnected);
             this.asyncClient.onDisConnect -= new AsyncClient.DisConnect(client_onDisConnect);
             this.asyncClient.onDataByteIn -= new AsyncClient.DataByteIn(client_onDataByteIn);
         }
         asyncClient = new AsyncClient();
         asyncClient.onConnected += new AsyncClient.Connected(client_onConnected);
         asyncClient.Connect(ip, port);
         asyncClient.onDataByteIn += new AsyncClient.DataByteIn(client_onDataByteIn);
         asyncClient.onDisConnect += new AsyncClient.DisConnect(client_onDisConnect);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Ejemplo n.º 2
0
        private void InitSocket(string ip,int port)
        {
            try
            {
                InitAsyncTimer();
                if (this.asyncClient != null)
                {
                    this.asyncClient.Dispose();
                    this.asyncClient.onConnected -= new AsyncClient.Connected(client_onConnected);
                    this.asyncClient.onDisConnect -= new AsyncClient.DisConnect(client_onDisConnect);
                    this.asyncClient.onDataByteIn -= new AsyncClient.DataByteIn(client_onDataByteIn);
                }
                asyncClient = new AsyncClient();
                asyncClient.onConnected += new AsyncClient.Connected(client_onConnected);
                asyncClient.Connect(ip, port);
                asyncClient.onDataByteIn += new AsyncClient.DataByteIn(client_onDataByteIn);
                asyncClient.onDisConnect += new AsyncClient.DisConnect(client_onDisConnect);
            }
            catch (Exception ex)
            {

            }
        }