如何关闭未完成AcceptEx操作的套接字?
Hey there, let's break down how AcceptEx behaves when you call it via a function pointer (as documentation recommends) and set a receive buffer size:
When you specify a receive buffer, this call won't complete until the client sends data—here's the critical detail from official docs:
If a receive buffer is provided, the overlapped operation will only finish after both the connection is accepted and data has been read from it.
If you need to check whether the connection has been accepted (even before any incoming data arrives), you can use the getsockopt function with the SO_CONNECT_TIME option. If the socket isn't connected yet, getsockopt will return a WSAENOTCONN error, indicating the connection handshake hasn't completed. Once the connection is established (regardless of whether data has been sent), this call will return the timestamp when the connection was accepted—letting you handle connection setup separately from waiting for incoming data.
内容的提问来源于stack exchange,提问作者Wad

