// 使用套接字客户端发送消息 static void SendMessage(SocketClient client, string data) { try { client.SendAsync(data); } catch (Exception ex) { Console.WriteLine("当发送消息时,发生异常:\n" + ex.Message); client.Close(); Console.WriteLine("客户端断开连接。"); } }
// User SocketClient to send message static void SendMessage(SocketClient client, string data) { try { client.SendAsync(data); } catch (Exception ex) { Console.WriteLine("Exception occured when sending message:\n" + ex.Message); client.Close(); Console.WriteLine("Client disconnected."); } }