UDP 编程中 recvfrom 函数。从哪个参数可以获取客户传来数据缓冲区的长度大小?谢谢。

解决方案 »

  1.   

    无法事先知道,所以一般尽量稍稍大点:
    For message-oriented sockets, data is extracted from the first enqueued message, up to the size of the buffer supplied. If the datagram or message is larger than the buffer supplied, the buffer is filled with the first part of the datagram, and recvfrom generates the error WSAEMSGSIZE. For unreliable protocols (for example, UDP) the excess data is lost.