lisuyun

在AcceptEx之后要设置

int err = setsockopt( pWxOl->m_sock,
SOL_SOCKET,
SO_UPDATE_ACCEPT_CONTEXT,
(char *)&sListenSocket,
sizeof(sListenSocket) );
这样在后面getsockname和getpeername才能拿到真正的IP地址。
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 theAcceptExfunction completes and the SO_UPDATE_ACCEPT_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.
否则会出现 WSAENOTCONN 套接口未连接。

分类:

技术点:

相关文章:

  • 2021-09-08
  • 2021-08-29
  • 2021-08-29
  • 2021-11-26
  • 2021-08-29
  • 2021-12-10
  • 2021-08-29
  • 2021-07-28
猜你喜欢
  • 2021-05-26
  • 2021-05-06
  • 2021-05-16
  • 2021-08-29
  • 2021-08-29
  • 2021-08-29
  • 2021-08-29
相关资源
相似解决方案