c++ - AcceptEx的第3个参数:lpOutputBuffer,应该怎么设置?
阿神
阿神 2017-04-17 11:09:25
0
1
672

在IOCP模型编程中,因为采用AcceptEx异步接受连接,所以要一次性提交许多AcceptEx,其中第3个参数lpOutputBuffer,看了msdn是用来存放客户端和服务端地址信息等数据的。 那么按道理说,一个AcceptEx对应着专属于它的一个buffer,但是看到msdn有段Remark是这样写的:

Using a single buffer improves performance. When using AcceptEx, the GetAcceptExSockaddrs function must be called to parse the buffer into its three distinct parts (data, local socket address, and remote socket address). On Windows XP and later, once the AcceptEx function completes and the SOUPDATEACCEPT_CONTEXT option is set on the accepted socket, the local address associated with the accepted socket can also be retrieved using the getsockname function. Likewise, the remote address associated with the accepted socket can be retrieved using the getpeername function.

无法理解加粗那句话的意思,是指用一个buffer(全局变量)来应付所有的AcceptEx以提高性能吗?

阿神
阿神

闭关修行中......

reply all(1)
小葫芦

This question is confusing without context.
The sentence before the passage you quoted is as follows:

A single output buffer receives the data, the local socket address (the server), and the remote socket address (the client).

It will become clear when combined with the context.
This clearly means using one buffer to receive data, local socket address and remote socket address at the same time, instead of dividing it into three buffers. Improve performance through this method.
It is precisely because of such a mechanism that it is said that GetAcceptExSockaddrs needs to be called to parse these three different pieces of data.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template