Beispiel #1
0
 //收到客户端发送的数据
 private void client_ReceiveCompleted(object sender, SocketEventArgs e)
 {
     if (ReceiveCompleted != null)
     {
         ReceiveCompleted(this, e);
     }
 }
Beispiel #2
0
 //向客户端发送数据完成
 private void client_SendCompleted(object sender, SocketEventArgs e)
 {
     if (SendCompleted != null)
     {
         SendCompleted(this, e);
     }
 }
Beispiel #3
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);
        }