为什么WSARecv接受的字节数会是由第三个参数来指定的呢?
我先是用WSASend发送14字节然后WsaRecv就会接受14字节 但是客户端之发送 了12字节啊
然后接下来我又发送了18字节后再用WSARECV结果也接受了18字节但是客户端一直都是发送12字节的阿
也就是说,WSARECV是在WSASEND之后调用的,但是接受的字节数却被第三个参数影响
在MSDN上面明明是说第三个参数是out用的啊应该是这个函数重写这个参数才对吖2.。。为什么WSARECV会是根据这个参数接受字节数呢?
我先是用WSASend发送14字节然后WsaRecv就会接受14字节 但是客户端之发送 了12字节啊
然后接下来我又发送了18字节后再用WSARECV结果也接受了18字节但是客户端一直都是发送12字节的阿
也就是说,WSARECV是在WSASEND之后调用的,但是接受的字节数却被第三个参数影响
在MSDN上面明明是说第三个参数是out用的啊应该是这个函数重写这个参数才对吖2.。。为什么WSARECV会是根据这个参数接受字节数呢?
s
[in] Descriptor identifying a connected socket.
lpBuffers
[in, out] Pointer to an array of WSABUF structures. Each WSABUF structure contains a pointer to a buffer and the length of the buffer.
dwBufferCount
[in] Number of WSABUF structures in the lpBuffers array.
lpNumberOfBytesRecvd
[out] Pointer to the number of bytes received by this call if the receive operation completes immediately.
lpFlags
[in, out] Pointer to flags.
lpOverlapped
[in] Pointer to a WSAOVERLAPPED structure (ignored for nonoverlapped sockets).
lpCompletionRoutine
[in] Pointer to the completion routine called when the receive operation has been completed (ignored for nonoverlapped sockets). 第3个参数是in
第4个参数才是out
第4个参数的意思是你实际接收的字节数。