读书人

C++应用实例十七

发布时间: 2008-12-26 09:28:37 作者: liuhuituzi

TCP下socket的send函数发送的字节数可能小于要求发送的字节数,send_n用得太频繁,没办法,自己写了一个。

  无甚技术含量,勉强够用^_^

  int send_n(SOCKET s, const char *buf, int len, int flags)

  {

  int result, old_len = len;

  do {

  result = send(s, buf, len, flags);

  if (result == SOCKET_ERROR)

  return SOCKET_ERROR;

  len -= result;

  buf += result;

  } while (len);

  return old_len;

  }

3COME考试频道为您精心整理,希望对您有所帮助,更多信息在http://www.reader8.net/exam/

读书人网 >复习指导

热点推荐