Beispiel #1
0
 /// <summary>
 /// 向对方发送数据
 /// </summary>
 /// <param name="byteData">数据内容</param>
 /// <param name="clientID">连接标识</param>
 public void SendData(byte[] byteData, int clientID)
 {
     if (byteData.Length == 0)
     {
         return;
     }
     if (_tcpMode == TcpMode.Client)
     {
         if (!Connected)
         {
             onError(_localTcpStruct, _remoteTcpStruct, TcpError.TcpClientNotConnected, null, TcpOptionType.SendData, null); return;
         }
         _ns.Write(byteData, 0, byteData.Length);
     }
     else if (_tcpMode == TcpMode.Server)
     {
         __listen__readTcp pclinet = GetListenClient(clientID);
         if (pclinet != null)
         {
             pclinet.SendData(byteData);
         }
         else
         {
             onError(_localTcpStruct, _remoteTcpStruct, TcpError.TcpClientNotConnected, null, TcpOptionType.SendData, pclinet);
         }
     }
     else
     {
         onError(_localTcpStruct, _remoteTcpStruct, TcpError.UnknownModeOrNotConnected, null, TcpOptionType.SendData, null);
     }
 }