Beispiel #1
0
 /// <summary>
 /// 发送数据的方法
 /// </summary>
 /// <param name="clientSocket"></param>
 /// <param name="msg"></param>
 private void SendMessage(Socket clientSocket, string msg)
 {
     if (clientSocket != null && clientSocket.Connected == true)
     {
         byte[] bytes = MessageHandle.PackData(msg);
         clientSocket.Send(bytes);
         //clientSocket.BeginSend(bytes, 0, bytes.Length, SocketFlags.None, ReceiveCallBack, clientSocket);
     }
 }
Beispiel #2
0
 /// <summary>
 /// 给服务器发送消息
 /// </summary>
 /// <param name="clientSocket"></param>
 /// <param name="msg"></param>
 private void SendMessage(Socket clientSocket, string msg)
 {
     if (clientSocket != null && clientSocket.Connected == true)
     {
         try
         {
             byte[] bytes = MessageHandle.PackData(msg);
             clientSocket.BeginSend(bytes, 0, bytes.Length, 0, SendMesCallBack, clientSocket);
         }
         catch (SocketException e)
         {
             Debug.Log(e);
         }
     }
     else
     {
         isConnected = false;
     }
 }