--- mstools/h/winsock.h 2018/08/09 18:21:05 1.1.1.2 +++ mstools/h/winsock.h 2018/08/09 18:22:59 1.1.1.3 @@ -1,9 +1,23 @@ /* WINSOCK.H--definitions to be used with the WINSOCK.DLL * + * This header file corresponds to version 1.1 of the Windows Sockets specification. + * * This file includes parts which are Copyright (c) 1982-1986 Regents * of the University of California. All rights reserved. The * Berkeley Software License Agreement specifies the terms and * conditions for redistribution. + * + * Change log: + * + * Fri Apr 23 16:31:01 1993 Mark Towfiq (towfiq@Microdyne.COM) + * New version from David Treadwell which adds extern "C" around + * __WSAFDIsSet() and removes "const" from buf param of + * WSAAsyncGetHostByAddr(). Added change log. + * + * Sat May 15 10:55:00 1993 David Treadwell (davidtr@microsoft.com) + * Fix the IN_CLASSC macro to account for class-D multicasts. + * Add AF_IPX == AF_NS. + * */ #ifndef _WINSOCKAPI_ @@ -21,7 +35,6 @@ */ typedef unsigned char u_char; typedef unsigned short u_short; -typedef unsigned short ushort; typedef unsigned int u_int; typedef unsigned long u_long; @@ -44,35 +57,44 @@ typedef u_int SOCKET; #endif /* FD_SETSIZE */ typedef struct fd_set { - u_short fd_count; /* how many are SET? */ + u_int fd_count; /* how many are SET? */ SOCKET fd_array[FD_SETSIZE]; /* an array of SOCKETs */ } fd_set; +#ifdef __cplusplus +extern "C" { +#endif + extern int PASCAL FAR __WSAFDIsSet(SOCKET, fd_set FAR *); -#define FD_CLR(fd, set) { \ +#ifdef __cplusplus +} +#endif + + +#define FD_CLR(fd, set) do { \ u_int __i; \ for (__i = 0; __i < ((fd_set FAR *)(set))->fd_count ; __i++) { \ if (((fd_set FAR *)(set))->fd_array[__i] == fd) { \ - while (__i < (u_int)(((fd_set FAR *)(set))->fd_count-1)) { \ + while (__i < ((fd_set FAR *)(set))->fd_count-1) { \ ((fd_set FAR *)(set))->fd_array[__i] = \ - ((fd_set FAR*)(set))->fd_array[__i+1]; \ + ((fd_set FAR *)(set))->fd_array[__i+1]; \ __i++; \ } \ ((fd_set FAR *)(set))->fd_count--; \ break; \ } \ } \ -} +} while(0) -#define FD_SET(fd, set) { \ +#define FD_SET(fd, set) do { \ if (((fd_set FAR *)(set))->fd_count < FD_SETSIZE) \ ((fd_set FAR *)(set))->fd_array[((fd_set FAR *)(set))->fd_count++]=fd;\ -} +} while(0) -#define FD_ZERO(set) ((fd_set FAR *)(set))->fd_count=0 +#define FD_ZERO(set) (((fd_set FAR *)(set))->fd_count=0) -#define FD_ISSET(fd, set) __WSAFDIsSet((int)fd, (fd_set FAR *)set) +#define FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)fd, (fd_set FAR *)set) /* * Structure used in select() call, taken from the BSD file sys/time.h. @@ -110,22 +132,22 @@ struct timeval { #define IOC_INOUT (IOC_IN|IOC_OUT) /* 0x20000000 distinguishes new & old ioctl's */ -#define _IO(x,y) (IOC_VOID|('x'<<8)|y) +#define _IO(x,y) (IOC_VOID|(x<<8)|y) #define _IOR(x,y,t) (IOC_OUT|(((long)sizeof(t)&IOCPARM_MASK)<<16)|(x<<8)|y) #define _IOW(x,y,t) (IOC_IN|(((long)sizeof(t)&IOCPARM_MASK)<<16)|(x<<8)|y) -#define FIONREAD _IOR('f', 127, int) /* get # bytes to read */ -#define FIONBIO _IOW('f', 126, int) /* set/clear non-blocking i/o */ -#define FIOASYNC _IOW('f', 125, int) /* set/clear async i/o */ +#define FIONREAD _IOR('f', 127, u_long) /* get # bytes to read */ +#define FIONBIO _IOW('f', 126, u_long) /* set/clear non-blocking i/o */ +#define FIOASYNC _IOW('f', 125, u_long) /* set/clear async i/o */ /* Socket I/O Controls */ -#define SIOCSHIWAT _IOW('s', 0, int) /* set high watermark */ -#define SIOCGHIWAT _IOR('s', 1, int) /* get high watermark */ -#define SIOCSLOWAT _IOW('s', 2, int) /* set low watermark */ -#define SIOCGLOWAT _IOR('s', 3, int) /* get low watermark */ -#define SIOCATMARK _IOR('s', 7, int) /* at oob mark? */ +#define SIOCSHIWAT _IOW('s', 0, u_long) /* set high watermark */ +#define SIOCGHIWAT _IOR('s', 1, u_long) /* get high watermark */ +#define SIOCSLOWAT _IOW('s', 2, u_long) /* set low watermark */ +#define SIOCGLOWAT _IOR('s', 3, u_long) /* get low watermark */ +#define SIOCATMARK _IOR('s', 7, u_long) /* at oob mark? */ /* * Structures returned by network data base library, taken from the @@ -136,8 +158,8 @@ struct timeval { struct hostent { char FAR * h_name; /* official name of host */ char FAR * FAR * h_aliases; /* alias list */ - int h_addrtype; /* host address type */ - int h_length; /* length of address */ + short h_addrtype; /* host address type */ + short h_length; /* length of address */ char FAR * FAR * h_addr_list; /* list of addresses */ #define h_addr h_addr_list[0] /* address, for backward compat */ }; @@ -149,21 +171,21 @@ struct hostent { struct netent { char FAR * n_name; /* official name of net */ char FAR * FAR * n_aliases; /* alias list */ - int n_addrtype; /* net address type */ + short n_addrtype; /* net address type */ u_long n_net; /* network # */ }; struct servent { char FAR * s_name; /* official service name */ char FAR * FAR * s_aliases; /* alias list */ - int s_port; /* port # */ + short s_port; /* port # */ char FAR * s_proto; /* protocol to use */ }; struct protoent { char FAR * p_name; /* official protocol name */ char FAR * FAR * p_aliases; /* alias list */ - int p_proto; /* protocol # */ + short p_proto; /* protocol # */ }; /* @@ -280,15 +302,15 @@ struct in_addr { #define IN_CLASSB_HOST 0x0000ffff #define IN_CLASSB_MAX 65536 -#define IN_CLASSC(i) (((long)(i) & 0xc0000000) == 0xc0000000) +#define IN_CLASSC(i) (((long)(i) & 0xe0000000) == 0xc0000000) #define IN_CLASSC_NET 0xffffff00 #define IN_CLASSC_NSHIFT 8 #define IN_CLASSC_HOST 0x000000ff #define INADDR_ANY (u_long)0x00000000 #define INADDR_LOOPBACK 0x7f000001 -#define INADDR_BROADCAST (u_long)0xffffffff /* must be masked */ -#define INADDR_NONE 0xffffffff /* -1 return */ +#define INADDR_BROADCAST (u_long)0xffffffff +#define INADDR_NONE 0xffffffff /* * Socket address, internet style. @@ -308,8 +330,8 @@ typedef struct WSAData { WORD wHighVersion; char szDescription[WSADESCRIPTION_LEN+1]; char szSystemStatus[WSASYS_STATUS_LEN+1]; - int iMaxSockets; - int iMaxUdpDg; + unsigned short iMaxSockets; + unsigned short iMaxUdpDg; char FAR * lpVendorInfo; } WSADATA; @@ -369,6 +391,24 @@ typedef WSADATA FAR *LPWSADATA; #define SO_TYPE 0x1008 /* get socket type */ /* + * Options for connect and disconnect data and options. Used only by + * non-TCP/IP transports such as DECNet, OSI TP4, etc. + */ +#define SO_CONNDATA 0x7000 +#define SO_CONNOPT 0x7001 +#define SO_DISCDATA 0x7002 +#define SO_DISCOPT 0x7003 +#define SO_CONNDATALEN 0x7004 +#define SO_CONNOPTLEN 0x7005 +#define SO_DISCDATALEN 0x7006 +#define SO_DISCOPTLEN 0x7007 + +/* + * TCP options. + */ +#define TCP_NODELAY 0x0001 + +/* * Address families. */ #define AF_UNSPEC 0 /* unspecified */ @@ -377,8 +417,10 @@ typedef WSADATA FAR *LPWSADATA; #define AF_IMPLINK 3 /* arpanet imp addresses */ #define AF_PUP 4 /* pup protocols: e.g. BSP */ #define AF_CHAOS 5 /* mit CHAOS protocols */ +#define AF_IPX 6 /* IPX and SPX */ #define AF_NS 6 /* XEROX NS protocols */ -#define AF_NBS 7 /* nbs protocols */ +#define AF_ISO 7 /* ISO protocols */ +#define AF_OSI AF_ISO /* OSI is ISO */ #define AF_ECMA 8 /* european computer manufacturers */ #define AF_DATAKIT 9 /* datakit protocols */ #define AF_CCITT 10 /* CCITT protocols, X.25 etc */ @@ -388,8 +430,9 @@ typedef WSADATA FAR *LPWSADATA; #define AF_LAT 14 /* LAT */ #define AF_HYLINK 15 /* NSC Hyperchannel */ #define AF_APPLETALK 16 /* AppleTalk */ +#define AF_NETBIOS 17 /* NetBios-style addresses */ -#define AF_MAX 17 +#define AF_MAX 18 /* * Structure used by kernel to store most @@ -419,7 +462,9 @@ struct sockproto { #define PF_PUP AF_PUP #define PF_CHAOS AF_CHAOS #define PF_NS AF_NS -#define PF_NBS AF_NBS +#define PF_IPX AF_IPX +#define PF_ISO AF_ISO +#define PF_OSI AF_OSI #define PF_ECMA AF_ECMA #define PF_DATAKIT AF_DATAKIT #define PF_CCITT AF_CCITT @@ -456,6 +501,8 @@ struct linger { #define MSG_MAXIOVLEN 16 +#define MSG_PARTIAL 0x8000 /* partial send or recv for message xport */ + /* * Define constant based on rfc883, used by gethostbyxxxx() calls. */ @@ -481,6 +528,7 @@ struct linger { */ #define WSAEINTR (WSABASEERR+4) #define WSAEBADF (WSABASEERR+9) +#define WSAEACCES (WSABASEERR+13) #define WSAEFAULT (WSABASEERR+14) #define WSAEINVAL (WSABASEERR+22) #define WSAEMFILE (WSABASEERR+24) @@ -526,6 +574,8 @@ struct linger { #define WSAESTALE (WSABASEERR+70) #define WSAEREMOTE (WSABASEERR+71) +#define WSAEDISCON (WSABASEERR+101) + /* * Extended Windows Sockets error constant definitions */ @@ -567,7 +617,9 @@ struct linger { #define NO_ADDRESS WSANO_ADDRESS /* - * Windows Sockets errors redefined as regular Berkeley error constants + * Windows Sockets errors redefined as regular Berkeley error constants. + * These are commented out in Windows NT to avoid conflicts with errno.h. + * Use the WSA constants instead. */ #if 0 #define EWOULDBLOCK WSAEWOULDBLOCK @@ -611,14 +663,18 @@ struct linger { /* Socket function prototypes */ +#ifdef __cplusplus +extern "C" { +#endif + SOCKET PASCAL FAR accept (SOCKET s, struct sockaddr FAR *addr, int FAR *addrlen); -int PASCAL FAR bind (SOCKET s, struct sockaddr FAR *addr, int namelen); +int PASCAL FAR bind (SOCKET s, const struct sockaddr FAR *addr, int namelen); int PASCAL FAR closesocket (SOCKET s); -int PASCAL FAR connect (SOCKET s, struct sockaddr FAR *name, int namelen); +int PASCAL FAR connect (SOCKET s, const struct sockaddr FAR *name, int namelen); int PASCAL FAR ioctlsocket (SOCKET s, long cmd, u_long FAR *argp); @@ -635,11 +691,7 @@ u_long PASCAL FAR htonl (u_long hostlong u_short PASCAL FAR htons (u_short hostshort); -#if 0 -struct in_addr PASCAL FAR inet_addr (char FAR * cp); -#else -unsigned long PASCAL inet_addr (char FAR *cp); -#endif +unsigned long PASCAL FAR inet_addr (const char FAR * cp); char FAR * PASCAL FAR inet_ntoa (struct in_addr in); @@ -654,16 +706,16 @@ int PASCAL FAR recv (SOCKET s, char FAR int PASCAL FAR recvfrom (SOCKET s, char FAR * buf, int len, int flags, struct sockaddr FAR *from, int FAR * fromlen); -long PASCAL FAR select (int nfds, fd_set FAR *readfds, fd_set far *writefds, - fd_set FAR *exceptfds, struct timeval far *timeout); +int PASCAL FAR select (int nfds, fd_set FAR *readfds, fd_set FAR *writefds, + fd_set FAR *exceptfds, const struct timeval FAR *timeout); -int PASCAL FAR send (SOCKET s, char FAR * buf, int len, int flags); +int PASCAL FAR send (SOCKET s, const char FAR * buf, int len, int flags); -int PASCAL FAR sendto (SOCKET s, char FAR * buf, int len, int flags, - struct sockaddr FAR *to, int tolen); +int PASCAL FAR sendto (SOCKET s, const char FAR * buf, int len, int flags, + const struct sockaddr FAR *to, int tolen); int PASCAL FAR setsockopt (SOCKET s, int level, int optname, - char FAR * optval, int optlen); + const char FAR * optval, int optlen); int PASCAL FAR shutdown (SOCKET s, int how); @@ -671,19 +723,21 @@ SOCKET PASCAL FAR socket (int af, int ty /* Database function prototypes */ -struct hostent FAR * PASCAL FAR gethostbyaddr(char FAR * addr, +struct hostent FAR * PASCAL FAR gethostbyaddr(const char FAR * addr, int len, int type); -struct hostent FAR * PASCAL FAR gethostbyname(char FAR * name); +struct hostent FAR * PASCAL FAR gethostbyname(const char FAR * name); -struct servent FAR * PASCAL FAR getservbyport(int port, char FAR * proto); +int PASCAL FAR gethostname (char FAR * name, int namelen); -struct servent FAR * PASCAL FAR getservbyname(char FAR * name, - char FAR * proto); +struct servent FAR * PASCAL FAR getservbyport(int port, const char FAR * proto); + +struct servent FAR * PASCAL FAR getservbyname(const char FAR * name, + const char FAR * proto); struct protoent FAR * PASCAL FAR getprotobynumber(int proto); -struct protoent FAR * PASCAL FAR getprotobyname(char FAR * name); +struct protoent FAR * PASCAL FAR getprotobyname(const char FAR * name); /* Microsoft Windows Extension function prototypes */ @@ -704,15 +758,16 @@ FARPROC PASCAL FAR WSASetBlockingHook(FA int PASCAL FAR WSACancelBlockingCall(void); HANDLE PASCAL FAR WSAAsyncGetServByName(HWND hWnd, u_int wMsg, - char FAR * name, char FAR * proto, + const char FAR * name, + const char FAR * proto, char FAR * buf, int buflen); HANDLE PASCAL FAR WSAAsyncGetServByPort(HWND hWnd, u_int wMsg, int port, - char FAR * proto, char FAR * buf, + const char FAR * proto, char FAR * buf, int buflen); HANDLE PASCAL FAR WSAAsyncGetProtoByName(HWND hWnd, u_int wMsg, - char FAR * name, char FAR * buf, + const char FAR * name, char FAR * buf, int buflen); HANDLE PASCAL FAR WSAAsyncGetProtoByNumber(HWND hWnd, u_int wMsg, @@ -720,11 +775,11 @@ HANDLE PASCAL FAR WSAAsyncGetProtoByNumb int buflen); HANDLE PASCAL FAR WSAAsyncGetHostByName(HWND hWnd, u_int wMsg, - char FAR * name, char FAR * buf, + const char FAR * name, char FAR * buf, int buflen); HANDLE PASCAL FAR WSAAsyncGetHostByAddr(HWND hWnd, u_int wMsg, - char FAR * addr, int len, int type, + const char FAR * addr, int len, int type, char FAR * buf, int buflen); int PASCAL FAR WSACancelAsyncRequest(HANDLE hAsyncTaskHandle); @@ -732,6 +787,12 @@ int PASCAL FAR WSACancelAsyncRequest(HAN int PASCAL FAR WSAAsyncSelect(SOCKET s, HWND hWnd, u_int wMsg, long lEvent); +int PASCAL FAR WSARecvEx (SOCKET s, char FAR * buf, int len, int *flags); + +#ifdef __cplusplus +} +#endif + /* Microsoft Windows Extended data types */ typedef struct sockaddr SOCKADDR; typedef struct sockaddr *PSOCKADDR; @@ -765,17 +826,21 @@ typedef struct protoent PROTOENT; typedef struct protoent *PPROTOENT; typedef struct protoent FAR *LPPROTOENT; +typedef struct timeval TIMEVAL; +typedef struct timeval *PTIMEVAL; +typedef struct timeval FAR *LPTIMEVAL; + /* * Windows message parameter composition and decomposition * macros. * * WSAMAKEASYNCREPLY is intended for use by the Windows Sockets implementation - * when constructing the response to a WSAGetXByY() + * when constructing the response to a WSAAsyncGetXByY() routine. */ #define WSAMAKEASYNCREPLY(buflen,error) MAKELONG(buflen,error) /* * WSAMAKESELECTREPLY is intended for use by the Windows Sockets implementation - * when constructing the response to WSAAsyncSelect() + * when constructing the response to WSAAsyncSelect(). */ #define WSAMAKESELECTREPLY(event,error) MAKELONG(event,error) /* @@ -804,3 +869,5 @@ typedef struct protoent FAR *LPPROTOENT; #define WSAGETSELECTERROR(lParam) HIWORD(lParam) #endif /* _WINSOCKAPI_ */ + +