send

此方法用于通过套接字发送数据。

特征符
int RiCOSSocket_send (RiCOSSocket *const me, 
   const char *buf, int bufLen);
参数
me

这是 RiCOSSocket 对象

buf

这是包含要发送的数据的常量字符串缓冲区

bufLen

这是缓冲区的长度

返回

此方法返回以下某个值:

示例

int RiCOSSocket_send(RiCOSSocket * const me, 
   const char * buf, int bufLen)
{
   int bytes_writ = 0;
   int n;

   if (me==NULL) return -1;

   while (bytes_writ < bufLen) {
      n = send(me->theSock, (char *)(buf + bytes_writ),
         bufLen - bytes_writ, 0);
      if (SOCKET_ERROR == n) {
         if (errno == EINTR) {
            continue;
         }
         else {
            return -1;
         }
      }
      bytes_writ += n;
   }
   return bytes_writ;
}

反馈