Exemplo n.º 1
0
        //客户端断开连接
        private void client_DisconnectCompleted(object sender, SocketEventArgs e)
        {
            //移除客户端
            lock (clients)
                clients.Remove((TCPListenerClient)e.Socket);

            e.Socket.DisconnectCompleted -= client_DisconnectCompleted;
            e.Socket.ReceiveCompleted    -= client_ReceiveCompleted;
            e.Socket.SendCompleted       -= client_SendCompleted;
            DisconnectCompleted?.Invoke(this, e);
        }
Exemplo n.º 2
0
 //向客户端发送数据完成
 private void client_SendCompleted(object sender, SocketEventArgs e)
 {
     SendCompleted?.Invoke(this, e);
 }