📄 f-b2.html
字号:
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb_2312-80">
<META NAME="Generator" CONTENT="Microsoft Word 97">
<TITLE>附录B</TITLE>
</HEAD>
<BODY>
<B><FONT FACE="黑体" LANG="ZH-CN" SIZE=5><P><A NAME="_Toc336626936"><A NAME="_Toc336793019"><A NAME="_Toc336793495">附录</FONT><FONT FACE="Arial" SIZE=5>B.2 Windows Sockets 2</FONT><FONT FACE="黑体" LANG="ZH-CN" SIZE=5>头文件</A></A></A></P>
</B></FONT><FONT FACE="宋体" LANG="ZH-CN" SIZE=3><P ALIGN="JUSTIFY"></P>
</FONT><FONT SIZE=3><P ALIGN="JUSTIFY">/* Winsock2.h</FONT><FONT FACE="宋体" LANG="ZH-CN" SIZE=3>-</FONT><FONT SIZE=3>definitions to be used with the WinSock 2.0</P>
<P ALIGN="JUSTIFY">DLL and</P>
<P ALIGN="JUSTIFY"> * WinSock 2.0 applications.</P>
<P ALIGN="JUSTIFY"> *</P>
<P ALIGN="JUSTIFY"> * This header file corresponds to version 2.0 of the</P>
<P ALIGN="JUSTIFY">WinSock specification.</P>
<P ALIGN="JUSTIFY"> *</P>
<P ALIGN="JUSTIFY"> * This file includes parts which are Copyright (c) 1982-</P>
<P ALIGN="JUSTIFY">1986 Regents</P>
<P ALIGN="JUSTIFY"> * of the University of California. All rights reserved.</P>
<P ALIGN="JUSTIFY">The</P>
<P ALIGN="JUSTIFY"> * Berkeley Software License Agreement specifies the terms</P>
<P ALIGN="JUSTIFY">and</P>
<P ALIGN="JUSTIFY"> * conditions for redistribution.</P>
<P ALIGN="JUSTIFY"> */</P>
<P ALIGN="JUSTIFY"></P>
<P ALIGN="JUSTIFY">#ifndef _WINSOCK2API_</P>
<P ALIGN="JUSTIFY">#define _WINSOCK2API_</P>
<P ALIGN="JUSTIFY"></P>
<P ALIGN="JUSTIFY">/*</P>
<P ALIGN="JUSTIFY"> * Pull in WINDOWS.H if necessary</P>
<P ALIGN="JUSTIFY"> */</P>
<P ALIGN="JUSTIFY">#ifndef _INC_WINDOWS</P>
<P ALIGN="JUSTIFY">#include <windows.h></P>
<P ALIGN="JUSTIFY">#endif /* _INC_WINDOWS */</P>
<P ALIGN="JUSTIFY"></P>
<P ALIGN="JUSTIFY">/*</P>
<P ALIGN="JUSTIFY"> * Basic system type definitions, taken from the BSD file</P>
<P ALIGN="JUSTIFY">sys/types.h.</P>
<P ALIGN="JUSTIFY"> */</P>
<P ALIGN="JUSTIFY">typedef unsigned char u_char;</P>
<P ALIGN="JUSTIFY">typedef unsigned short u_short;</P>
<P ALIGN="JUSTIFY">typedef unsigned int u_int;</P>
<P ALIGN="JUSTIFY">typedef unsigned long u_long;</P>
<P ALIGN="JUSTIFY"></P>
<P ALIGN="JUSTIFY">/*</P>
<P ALIGN="JUSTIFY"> * The new type to be used in all</P>
<P ALIGN="JUSTIFY"> * instances which refer to sockets.</P>
<P ALIGN="JUSTIFY"> */</P>
<P ALIGN="JUSTIFY">typedef u_int SOCKET;</P>
<P ALIGN="JUSTIFY"></P>
<P ALIGN="JUSTIFY">/*</P>
<P ALIGN="JUSTIFY"> * Select uses arrays of SOCKETs. These macros manipulate</P>
<P ALIGN="JUSTIFY">such</P>
<P ALIGN="JUSTIFY"> * arrays. FD_SETSIZE may be defined by the user before</P>
<P ALIGN="JUSTIFY">including</P>
<P ALIGN="JUSTIFY"> * this file, but the default here should be >= 64.</P>
<P ALIGN="JUSTIFY"> *</P>
<P ALIGN="JUSTIFY"> * CAVEAT IMPLEMENTOR and USER: THESE MACROS AND TYPES MUST</P>
<P ALIGN="JUSTIFY">BE</P>
<P ALIGN="JUSTIFY"> * INCLUDED IN WINSOCK.H EXACTLY AS SHOWN HERE.</P>
<P ALIGN="JUSTIFY"> */</P>
<P ALIGN="JUSTIFY">#ifndef FD_SETSIZE</P>
<P ALIGN="JUSTIFY">#define FD_SETSIZE 64</P>
<P ALIGN="JUSTIFY">#endif /* FD_SETSIZE */</P>
<P ALIGN="JUSTIFY"></P>
<P ALIGN="JUSTIFY">typedef struct fd_set {</P>
<P ALIGN="JUSTIFY"> u_short fd_count; /* how many are SET?</P>
<P ALIGN="JUSTIFY">*/</P>
<P ALIGN="JUSTIFY"> SOCKET fd_array[FD_SETSIZE]; /* an array of</P>
<P ALIGN="JUSTIFY">SOCKETs */</P>
<P ALIGN="JUSTIFY">} fd_set;</P>
<P ALIGN="JUSTIFY"></P>
<P ALIGN="JUSTIFY">extern int PASCAL FAR __WSAFDIsSet(SOCKET, fd_set FAR *);</P>
<P ALIGN="JUSTIFY"></P>
<P ALIGN="JUSTIFY">#define FD_CLR(fd, set) do { \</P>
<P ALIGN="JUSTIFY"> u_int __i; \</P>
<P ALIGN="JUSTIFY"> for (__i = 0; __i < ((fd_set FAR *)(set))->fd_count ;</P>
<P ALIGN="JUSTIFY">__i++) { \</P>
<P ALIGN="JUSTIFY"> if (((fd_set FAR *)(set))->fd_array[__i] == fd) { \</P>
<P ALIGN="JUSTIFY"> while (__i < ((fd_set FAR *)(set))->fd_count-1)</P>
<P ALIGN="JUSTIFY">{ \</P>
<P ALIGN="JUSTIFY"> ((fd_set FAR *)(set))->fd_array[__i] = \</P>
<P ALIGN="JUSTIFY"> ((fd_set FAR *)(set))->fd_array[__i+1];</P>
<P ALIGN="JUSTIFY">\</P>
<P ALIGN="JUSTIFY"> __i++; \</P>
<P ALIGN="JUSTIFY"> } \</P>
<P ALIGN="JUSTIFY"> ((fd_set FAR *)(set))->fd_count</FONT><FONT FACE="宋体" LANG="ZH-CN" SIZE=3>-</FONT><FONT SIZE=3>; \</P>
<P ALIGN="JUSTIFY"> break; \</P>
<P ALIGN="JUSTIFY"> } \</P>
<P ALIGN="JUSTIFY"> } \</P>
<P ALIGN="JUSTIFY">} while(0)</P>
<P ALIGN="JUSTIFY"></P>
<P ALIGN="JUSTIFY">#define FD_SET(fd, set) do { \</P>
<P ALIGN="JUSTIFY"> if (((fd_set FAR *)(set))->fd_count < FD_SETSIZE) \</P>
<P ALIGN="JUSTIFY"> ((fd_set FAR *)(set))->fd_array[((fd_set FAR</P>
<P ALIGN="JUSTIFY">*)(set))->fd_count++]=fd;\</P>
<P ALIGN="JUSTIFY">} while(0)</P>
<P ALIGN="JUSTIFY"></P>
<P ALIGN="JUSTIFY">#define FD_ZERO(set) (((fd_set FAR *)(set))->fd_count=0)</P>
<P ALIGN="JUSTIFY"></P>
<P ALIGN="JUSTIFY">#define FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)fd, (fd_set</P>
<P ALIGN="JUSTIFY">FAR *)set)</P>
<P ALIGN="JUSTIFY"></P>
<P ALIGN="JUSTIFY">/*</P>
<P ALIGN="JUSTIFY"> * Structure used in select() call, taken from the BSD file</P>
<P ALIGN="JUSTIFY">sys/time.h.</P>
<P ALIGN="JUSTIFY"> */</P>
<P ALIGN="JUSTIFY">struct timeval {</P>
<P ALIGN="JUSTIFY"> long tv_sec; /* seconds */</P>
<P ALIGN="JUSTIFY"> long tv_usec; /* and microseconds */</P>
<P ALIGN="JUSTIFY">};</P>
<P ALIGN="JUSTIFY"></P>
<P ALIGN="JUSTIFY">/*</P>
<P ALIGN="JUSTIFY"> * Operations on timevals.</P>
<P ALIGN="JUSTIFY"> *</P>
<P ALIGN="JUSTIFY"> * NB: timercmp does not work for >= or <=.</P>
<P ALIGN="JUSTIFY"> */</P>
<P ALIGN="JUSTIFY">#define timerisset(tvp) ((tvp)->tv_sec || (tvp)-</P>
<P ALIGN="JUSTIFY">>tv_usec)</P>
<P ALIGN="JUSTIFY">#define timercmp(tvp, uvp, cmp) \</P>
<P ALIGN="JUSTIFY"> ((tvp)->tv_sec cmp (uvp)->tv_sec || \</P>
<P ALIGN="JUSTIFY"> (tvp)->tv_sec == (uvp)->tv_sec && (tvp)->tv_usec</P>
<P ALIGN="JUSTIFY">cmp (uvp)->tv_usec)</P>
<P ALIGN="JUSTIFY">#define timerclear(tvp) (tvp)->tv_sec = (tvp)-</P>
<P ALIGN="JUSTIFY">>tv_usec = 0</P>
<P ALIGN="JUSTIFY"></P>
<P ALIGN="JUSTIFY">/*</P>
<P ALIGN="JUSTIFY"> * Commands for ioctlsocket(), taken from the BSD file</P>
<P ALIGN="JUSTIFY">fcntl.h.</P>
<P ALIGN="JUSTIFY"> *</P>
<P ALIGN="JUSTIFY"> *</P>
<P ALIGN="JUSTIFY"> * Ioctl's have the command encoded in the lower word,</P>
<P ALIGN="JUSTIFY"> * and the size of any in or out parameters in the upper</P>
<P ALIGN="JUSTIFY"> * word. The high 2 bits of the upper word are used</P>
<P ALIGN="JUSTIFY"> * to encode the in/out status of the parameter; for now</P>
<P ALIGN="JUSTIFY"> * we restrict parameters to at most 128 bytes.</P>
<P ALIGN="JUSTIFY"> */</P>
<P ALIGN="JUSTIFY">#define IOCPARM_MASK 0x7f /* parameters must</P>
<P ALIGN="JUSTIFY">be < 128 bytes */</P>
<P ALIGN="JUSTIFY">#define IOC_VOID 0x20000000 /* no parameters */</P>
<P ALIGN="JUSTIFY">#define IOC_OUT 0x40000000 /* copy out</P>
<P ALIGN="JUSTIFY">parameters */</P>
<P ALIGN="JUSTIFY">#define IOC_IN 0x80000000 /* copy in</P>
<P ALIGN="JUSTIFY">parameters */</P>
<P ALIGN="JUSTIFY">#define IOC_INOUT (IOC_IN|IOC_OUT)</P>
<P ALIGN="JUSTIFY"> /* 0x20000000</P>
<P ALIGN="JUSTIFY">distinguishes new &</P>
<P ALIGN="JUSTIFY"> old ioctl's */</P>
<P ALIGN="JUSTIFY">#define _IO(x,y) (IOC_VOID|(x<<8)|y)</P>
<P ALIGN="JUSTIFY"></P>
<P ALIGN="JUSTIFY">#define _IOR(x,y,t)</P>
<P ALIGN="JUSTIFY">(IOC_OUT|(((long)sizeof(t)&IOCPARM_MASK)<<16)|(x<<8)|y)</P>
<P ALIGN="JUSTIFY"></P>
<P ALIGN="JUSTIFY">#define _IOW(x,y,t)</P>
<P ALIGN="JUSTIFY">(IOC_IN|(((long)sizeof(t)&IOCPARM_MASK)<<16)|(x<<8)|y)</P>
<P ALIGN="JUSTIFY"></P>
<P ALIGN="JUSTIFY">#define FIONREAD _IOR('f', 127, u_long) /* get # bytes to</P>
<P ALIGN="JUSTIFY">read */</P>
<P ALIGN="JUSTIFY">#define FIONBIO _IOW('f', 126, u_long) /* set/clear non-</P>
<P ALIGN="JUSTIFY">blocking i/o */</P>
<P ALIGN="JUSTIFY">#define FIOASYNC _IOW('f', 125, u_long) /* set/clear</P>
<P ALIGN="JUSTIFY">async i/o */</P>
<P ALIGN="JUSTIFY"></P>
<P ALIGN="JUSTIFY">/* Socket I/O Controls */</P>
<P ALIGN="JUSTIFY">#define SIOCSHIWAT _IOW('s', 0, u_long) /* set high</P>
<P ALIGN="JUSTIFY">watermark */</P>
<P ALIGN="JUSTIFY">#define SIOCGHIWAT _IOR('s', 1, u_long) /* get high</P>
<P ALIGN="JUSTIFY">watermark */</P>
<P ALIGN="JUSTIFY">#define SIOCSLOWAT _IOW('s', 2, u_long) /* set low</P>
<P ALIGN="JUSTIFY">watermark */</P>
<P ALIGN="JUSTIFY">#define SIOCGLOWAT _IOR('s', 3, u_long) /* get low</P>
<P ALIGN="JUSTIFY">watermark */</P>
<P ALIGN="JUSTIFY">#define SIOCATMARK _IOR('s', 7, u_long) /* at oob mark?</P>
<P ALIGN="JUSTIFY">*/</P>
<P ALIGN="JUSTIFY"></P>
<P ALIGN="JUSTIFY">/*</P>
<P ALIGN="JUSTIFY"> * Structures returned by network data base library, taken</P>
<P ALIGN="JUSTIFY">from the</P>
<P ALIGN="JUSTIFY"> * BSD file netdb.h. All addresses are supplied in host</P>
<P ALIGN="JUSTIFY">order, and</P>
<P ALIGN="JUSTIFY"> * returned in network order (suitable for use in system</P>
<P ALIGN="JUSTIFY">calls).</P>
<P ALIGN="JUSTIFY"> */</P>
<P ALIGN="JUSTIFY"></P>
<P ALIGN="JUSTIFY">struct hostent {</P>
<P ALIGN="JUSTIFY"> char FAR * h_name; /* official name of</P>
<P ALIGN="JUSTIFY">host */</P>
<P ALIGN="JUSTIFY"> char FAR * FAR * h_aliases; /* alias list */</P>
<P ALIGN="JUSTIFY"> short h_addrtype; /* host address type</P>
<P ALIGN="JUSTIFY">*/</P>
<P ALIGN="JUSTIFY"> short h_length; /* length of address</P>
<P ALIGN="JUSTIFY">*/</P>
<P ALIGN="JUSTIFY"> char FAR * FAR * h_addr_list; /* list of</P>
<P ALIGN="JUSTIFY">addresses */</P>
<P ALIGN="JUSTIFY">#define h_addr h_addr_list[0] /* address, for</P>
<P ALIGN="JUSTIFY">backward compat */</P>
<P ALIGN="JUSTIFY">};</P>
<P ALIGN="JUSTIFY"></P>
<P ALIGN="JUSTIFY">/*</P>
<P ALIGN="JUSTIFY"> * It is assumed here that a network number</P>
<P ALIGN="JUSTIFY"> * fits in 32 bits.</P>
<P ALIGN="JUSTIFY"> */</P>
<P ALIGN="JUSTIFY">struct netent {</P>
<P ALIGN="JUSTIFY"> char FAR * n_name; /* official name of</P>
<P ALIGN="JUSTIFY">net */</P>
<P ALIGN="JUSTIFY"> char FAR * FAR * n_aliases; /* alias list */</P>
<P ALIGN="JUSTIFY"> short n_addrtype; /* net address type</P>
<P ALIGN="JUSTIFY">*/</P>
<P ALIGN="JUSTIFY"> u_long n_net; /* network # */</P>
<P ALIGN="JUSTIFY">};</P>
<P ALIGN="JUSTIFY"></P>
<P ALIGN="JUSTIFY">struct servent {</P>
<P ALIGN="JUSTIFY"> char FAR * s_name; /* official service</P>
<P ALIGN="JUSTIFY">name */</P>
<P ALIGN="JUSTIFY"> char FAR * FAR * s_aliases; /* alias list */</P>
<P ALIGN="JUSTIFY"> short s_port; /* port # */</P>
<P ALIGN="JUSTIFY"> char FAR * s_proto; /* protocol to use</P>
<P ALIGN="JUSTIFY">*/</P>
<P ALIGN="JUSTIFY">};</P>
<P ALIGN="JUSTIFY"></P>
<P ALIGN="JUSTIFY">struct protoent {</P>
<P ALIGN="JUSTIFY"> char FAR * p_name; /* official protocol</P>
<P ALIGN="JUSTIFY">name */</P>
<P ALIGN="JUSTIFY"> char FAR * FAR * p_aliases; /* alias list */</P>
<P ALIGN="JUSTIFY"> short p_proto; /* protocol # */</P>
<P ALIGN="JUSTIFY">};</P>
<P ALIGN="JUSTIFY"></P>
<P ALIGN="JUSTIFY">/*</P>
<P ALIGN="JUSTIFY"> * Constants and structures defined by the internet system,</P>
<P ALIGN="JUSTIFY"> * Per RFC 790, September 1981, taken from the BSD file</P>
<P ALIGN="JUSTIFY">netinet/in.h.</P>
<P ALIGN="JUSTIFY"> */</P>
<P ALIGN="JUSTIFY"></P>
<P ALIGN="JUSTIFY">/*</P>
<P ALIGN="JUSTIFY"> * Protocols</P>
<P ALIGN="JUSTIFY"> */</P>
<P ALIGN="JUSTIFY">#define IPPROTO_IP 0 /* dummy for</P>
<P ALIGN="JUSTIFY">IP */</P>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -