Exemple #1
0
 /**
  * 分包发送数据
  * 会再次分割数据,同时添加头
  * 对应的要用readALL
  * @param data
  * @return
  */
 public bool SendSplitData(byte[] data)
 {
     if (getCloseState())
     {
         return(false);
     }
     byte[][] result = null;
     if (dataLen == 0)
     {
         result = PackagetSub.splitData(data);
     }
     else
     {
         PackagetSub sub = new PackagetSub();
         result = sub.Split(data, dataLen);
     }
     for (int i = 0; i < result.Length; i++)
     {
         if (!SendData(result[i]))
         {
             //一次发送失败则返回失败
             return(false);
         }
     }
     return(true);
 }
Exemple #2
0
        public int SendSplitData(byte[] data)
        {
            if (data == null)
            {
                return(0);
            }
            int r = 0;

            byte[][] sendData = null;
            if (dataLen == 0)
            {
                sendData = PackagetSub.splitData(data);
            }
            else
            {
                PackagetSub sub = new PackagetSub();
                sendData = sub.Split(data, dataLen);
            }
            for (int i = 0; i < sendData.Length; i++)
            {
                r += SendData(sendData[i]);
            }
            return(r);
        }