Beispiel #1
0
        private void AcceptCallback(IAsyncResult asyncResult)
        {
            Socket socket = null;

            try
            {
                socket = Sock.EndAccept(asyncResult);
            }
            catch (ObjectDisposedException) { return; }
            catch (Exception ex)
            {
                EventProvider.ExecuteErrorHandler(ex, SocketErrorLocation.EndStart);
                return;
            }

            TcpReceiveSocket receiveSocket = new TcpReceiveSocket(socket, SocketSide.Client, EventProvider);

            if (receiveSocket.Start())
            {
                TcpClientSockets.Add(receiveSocket);
                TcpClientSockets.TrimExcess();
            }

            EventProvider.ExecuteHandshakeHandler(((IPEndPoint)socket.RemoteEndPoint).Address, receiveSocket);

            Sock.BeginAccept(AcceptCallback, null);
        }
Beispiel #2
0
        private void ConnectionCallback(IAsyncResult asyncResult)
        {
            try
            {
                Sock.EndConnect(asyncResult);
            }
            catch (Exception ex)
            {
                EventProvider.ExecuteErrorHandler(ex, SocketErrorLocation.EndStart);
                return;
            }

            TcpReceiveSocket receiveSocket = new TcpReceiveSocket(Sock, SocketSide.Client, EventProvider);

            receiveSocket.Start();

            EventProvider.ExecuteHandshakeHandler(((IPEndPoint)Sock.RemoteEndPoint).Address, null);
        }