码迷,mamicode.com
首页 > 其他好文 > 详细

INVALID_SOCKET的值

时间:2014-08-02 18:08:13      阅读:867      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   os   strong   io   for   

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

INVALID_SOCKET的值,布布扣,bubuko.com

INVALID_SOCKET的值

标签:style   blog   http   color   os   strong   io   for   

原文地址:http://www.cnblogs.com/zhaoxinshanwei/p/3887180.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!