示例#1
0
        private void EndGetClient(IAsyncResult res)
        {
            try
            {
                TcpClient tcpClient = listener.EndAcceptTcpClient(res);
                Client client = new Client(tcpClient);
                client.DataReceived += Client_DataReceived;

                HandshakeRequest req = new HandshakeRequest(1);
                client.Send(req);

                clients.Add(client);
            }
            catch (SocketException ex)
            {
                //if (ex.Err)
            }
            catch (ObjectDisposedException)
            {
                return;
            }

            BeginAccept();
        }