예제 #1
0
 private void acceptCallback(IAsyncResult ar)
 {
     try
     {
         timer.Enabled = false;
         socket        = listenSocket.EndAccept(ar);
         DccStateObject dso = new DccStateObject();
         socket.BeginReceive(dso.Buffer, 0, DccStateObject.BufferSize, SocketFlags.None, new AsyncCallback(receiveCallback), dso);
         listenSocket.Close();
         if (socket.Connected)
         {
             Connected();
         }
         else
         {
             if (EtablishFailed != null)
             {
                 EtablishFailed(this, new EventArgs());
             }
             container.Remove(this);
         }
     }
     catch
     {
         if (EtablishFailed != null)
         {
             EtablishFailed(this, new EventArgs());
         }
         container.Remove(this);
     }
 }
예제 #2
0
        private void receiveCallback(IAsyncResult ar)
        {
            DccStateObject dso = (DccStateObject)ar.AsyncState;

            try
            {
                int intRead = socket.EndReceive(ar);
                if (intRead > 0)
                {
                    OnData(dso.Buffer, intRead);
                    socket.BeginReceive(dso.Buffer, 0, DccStateObject.BufferSize, SocketFlags.None, new AsyncCallback(receiveCallback), dso);
                }
                else
                {
                    CloseSocket();
                    Disconnected();
                    container.Remove(this);
                }
            }
            catch
            {
                CloseSocket();
                Disconnected();
                container.Remove(this);
            }
        }
예제 #3
0
        private void connectCallback(IAsyncResult ar)
        {
            try
            {
                socket.EndConnect(ar);
            }
            catch
            {
                if (EtablishFailed != null)
                {
                    EtablishFailed(this, new EventArgs());
                }
                return;
            }

            if (socket.Connected)
            {
                DccStateObject dso = new DccStateObject();
                socket.BeginReceive(dso.Buffer, 0, DccStateObject.BufferSize, SocketFlags.None, new AsyncCallback(receiveCallback), dso);
                Connected();
            }
            else
            {
                CloseSocket();
                if (EtablishFailed != null)
                {
                    EtablishFailed(this, new EventArgs());
                }
                container.Remove(this);
            }
        }
예제 #4
0
파일: DCCBase.cs 프로젝트: dab85/irc-sharp
        private void connectCallback(IAsyncResult ar)
        {
            try
            {
                socket.EndConnect(ar);
            }
            catch
            {
                if (EtablishFailed != null)
                    EtablishFailed(this, new EventArgs());
                return;
            }

            if (socket.Connected)
            {
                DccStateObject dso = new DccStateObject();
                socket.BeginReceive(dso.Buffer, 0, DccStateObject.BufferSize, SocketFlags.None, new AsyncCallback(receiveCallback), dso);
                Connected();
            }
            else
            {
                CloseSocket();
                if (EtablishFailed!=null)
                    EtablishFailed(this, new EventArgs());
                container.Remove(this);
            }
        }
예제 #5
0
파일: DCCBase.cs 프로젝트: dab85/irc-sharp
 private void acceptCallback(IAsyncResult ar)
 {
     try
     {
         timer.Enabled = false;
         socket = listenSocket.EndAccept(ar);
         DccStateObject dso = new DccStateObject();
         socket.BeginReceive(dso.Buffer, 0, DccStateObject.BufferSize, SocketFlags.None, new AsyncCallback(receiveCallback), dso);
         listenSocket.Close();
         if (socket.Connected)
             Connected();
         else
         {
             if (EtablishFailed!=null)
                 EtablishFailed(this, new EventArgs());
             container.Remove(this);
         }
     }
     catch
     {
         if (EtablishFailed!=null)
             EtablishFailed(this, new EventArgs());
         container.Remove(this);
     }
 }