Example #1
0
 void Callback(IAsyncResult ar)
 {
     try
     {
         var s = _socket.EndAccept(ar);
         SocketAccepted?.Invoke(s);
         _socket.BeginAccept(Callback, null);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Example #2
0
        void callback(IAsyncResult ar)
        {
            try
            {
                Socket s = this.s.EndAccept(ar); //Ends the thread?

                SocketAccepted?.Invoke(s);       //若事件沒被觸發就以s觸發
                this.s.BeginAccept(callback, null);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Example #3
0
        private void AcceptCallback(IAsyncResult ar)
        {
            try
            {
                Socket socket = serverSocket.EndAccept(ar);

                SocketAccepted?.Invoke(this, new SocketAcceptedEventHandler(socket));

                serverSocket.BeginAccept(AcceptCallback, null);
            }
            catch
            {
            }
        }
Example #4
0
        private void Callback(IAsyncResult result)
        {
            try {
                Socket s = Socket.EndAccept(result);
                SocketAccepted?.Invoke(new SocketAcceptedEventArgs(s));
                Socket.BeginAccept(Callback, Socket);
            }
            catch {
                //Console.WriteLine("Unhandled exception in TcpListener class : TODO");

                throw;
                // TODO: Exception handling
            }
        }
Example #5
0
        private void callback(IAsyncResult ar)
        {
            try
            {
                Socket s = this.s.EndAccept(ar);

                SocketAccepted?.Invoke(s);

                this.s.BeginAccept(callback, null);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Example #6
0
 private void CallbackAccept(IAsyncResult ar)
 {
     try
     {
         Socket handler = _socket.EndAccept(ar);
         if (SocketAccepted != null)
         {
             SocketAccepted.Invoke(handler);
         }
         _socket.BeginAccept(new AsyncCallback(CallbackAccept), null);
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
Example #7
0
 public void SetConnectionAcceptedCallback(SocketAccepted callback)
 {
     this._socketAccepted = callback;
 }