首页 > 代码库 > INVALID_SOCKET的值
INVALID_SOCKET的值
INVALID_SOCKET的值
(2011-06-26 15:06:45)
标签:
杂谈
INVALID_SOCKET的值不是-1,原因参考basetsd.h和WinSock2.h:
typedef _W64 unsigned int UINT_PTR, *PUINT_PTR;
typedef UINT_PTR SOCKET;
#define INVALID_SOCKET (SOCKET)(~0)
(~0)的值为-1;
(SOCKET)(~0)的值为:十六进制0xFFFFFFFF(十进制4294967295)。
To abort a connection, release a socket handle, and discard data pending for writing, do:
closesocket(sock);
sock = INVALID_SOCKET; // do not make further use of sock.
To flush a sock handle, gracefully close the socket, and release the socket handle in the
background:
DisconnectEx(sock, NULL, 0, 0); // retrieve this function pointer with WSAIoctl(WSAID_DISCONNECTEX).
closesocket(sock);
sock = INVALID_SOCKET; // do not make further use of sock.
http://msdn.microsoft.com/en-us/library/ms737582(VS.85).aspx
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。