macwinsock.h

Go to the documentation of this file.
00001 /* Copyright (c) 1995-1997, Altura Software, Inc. All rights reserved.  */
00002 
00003 /*
00004    winsock.h
00005    
00006    This header file corresponds to version 1.1 of the Windows Sockets
00007    specification.
00008    
00009    Parts of this file Copyright (c) 1982-1986, Regents of the University
00010    of California, Berkeley. All rights reserved. The Berkeley Software
00011    License Agreement specifies the terms and conditions for redistribution.
00012 */
00013 
00014 #ifndef _WINSOCKAPI_
00015 #define _WINSOCKAPI_
00016 
00017 /* Macintosh specific headers */
00018 #if !defined( __TYPES__ )
00019 #include <sys/Types.h>
00020 #endif
00021 
00022 #if !defined( __MIXEDMODE__ )
00023 #include <MixedMode.h>
00024 #endif
00025 
00026 #if !defined( _NMMESSAGE_H_ )
00027 #include "nmmessage.h"
00028 #endif
00029 /* End Macintosh specific headers   */
00030 
00031 /*
00032  * Basic system type definitions, taken from the BSD file sys/types.h.
00033  */
00034 
00035 #ifndef TRUE
00036 #define TRUE 1
00037 #endif
00038 
00039 #ifndef FALSE
00040 #define FALSE 0
00041 #endif
00042 
00043 typedef unsigned char   u_char;
00044 typedef unsigned short  u_short;
00045 typedef unsigned int u_int;
00046 typedef unsigned long   u_long;
00047 
00048 typedef u_int        SOCKET;
00049 
00050 /* Optional defines from Windows */
00051 #if !defined( _NM_NO_MSW_TYPES_ )
00052 
00053 // #if !defined( HANDLE )
00054 //    #define HANDLE    unsigned long
00055 // #endif
00056    
00057    #if !defined( MAKELONG )
00058       #define MAKELONG(loshort,hishort)   \
00059          ((u_long)(((long)hishort << 16) | ((short)loshort & 0xFFFF)))
00060    #endif
00061    
00062    #if !defined( LOWORD )
00063       #define LOWORD(thelong) \
00064          ((u_short)((long) thelong & 0xFFFF))
00065    #endif
00066    
00067    #if !defined( HIWORD )
00068       #define HIWORD(thelong) \
00069          ((u_short)(((long) thelong >> 16) & 0xFFFF))
00070    #endif
00071    
00072 #endif
00073 
00074 /*
00075  * select() uses arrays of SOCKETs. These macros manipulate such arrays.
00076  * FD_SETSIZE may be defined by the user before including this file, but
00077  * the default here should be >= 64.
00078  *
00079  * CAVEAT IMPLEMENTOR AND USER: These macros and types MUST be included
00080  * in winsock.h exactly as shown here.
00081  */
00082 
00083 #ifndef FD_SETSIZE
00084 #define FD_SETSIZE   64
00085 #endif   /* ndef FD_SETSIZE   */
00086 
00087 //typedef struct fd_set
00088 //{
00089 // u_int fd_count;            /* how many are SET? */
00090 // SOCKET   fd_array[FD_SETSIZE];   /* an array of SOCKETs  */
00091 //} fd_set;
00092 
00093 extern pascal int __WSAFDIsSet( SOCKET, fd_set * );
00094 
00095 #define FD_CLR(fd, set) \
00096 do                                              \
00097 {                                               \
00098    u_int __i;                                   \
00099    for (__i = 0; __i < ((fd_set *)(set))->fd_count ; __i++) \
00100    {                                            \
00101       if (((fd_set *)(set))->fd_array[__i] == fd)           \
00102       {                                         \
00103          while (__i < ((fd_set *)(set))->fd_count-1)     \
00104          {                                      \
00105                 ((fd_set *)(set))->fd_array[__i] =          \
00106                     ((fd_set *)(set))->fd_array[__i+1];        \
00107                 __i++;                                \
00108             }                                      \
00109             ((fd_set *)(set))->fd_count--;                  \
00110             break;                                    \
00111         }                                          \
00112     }                                           \
00113 } while ( 0 )
00114 
00115 #define FD_SET(fd, set) \
00116 do                                                    \
00117 {                                                     \
00118    if (((fd_set *)(set))->fd_count < FD_SETSIZE)                  \
00119       ((fd_set *)(set))->fd_array[((fd_set *)(set))->fd_count++]=fd; \
00120 } while ( 0 )
00121 
00122 #define FD_ZERO(set) (((fd_set *)(set))->fd_count=0)
00123 
00124 #define FD_ISSET(fd, set)  __WSAFDIsSet((SOCKET)fd, (fd_set *)set)
00125 
00126 /*
00127  * Structure used in select() call, taken from the BSD file sys/time.h.
00128  */
00129 
00130 //struct timeval
00131 //{
00132 // long  tv_sec;     /* seconds           */
00133 // long  tv_usec; /* and microseconds  */
00134 //};
00135 
00136 /*
00137  * Operations on timevals
00138  *
00139  * NB: timercmp does not work for >= or <=
00140  */
00141 
00142 #define timerisset(tvp)         ((tvp)->tv_sec || (tvp)->tv_usec)
00143 
00144 #define timercmp(tvp, uvp, cmp)  \
00145    ((tvp)->tv_sec cmp (uvp)->tv_sec || \
00146     (tvp)->tv_sec == (uvp)->tv_sec && (tvp)->tv_usec cmp (uvp)->tv_usec)
00147 
00148 #define timerclear(tvp)         (tvp)->tv_sec = (tvp)->tv_usec = 0
00149 
00150 /*
00151  * Commands for ioctlsocket(),  taken from the BSD file fcntl.h.
00152  *
00153  *
00154  * Ioctl's have the command encoded in the lower word,
00155  * and the size of any in or out parameters in the upper
00156  * word.  The high 2 bits of the upper word are used
00157  * to encode the in/out status of the parameter; for now
00158  * we restrict parameters to at most 128 bytes.
00159  */
00160 
00161 #define IOCPARM_MASK    0x7F            /* parameters must be < 128 bytes */
00162 #define IOC_VOID        0x20000000      /* no parameters */
00163 #define IOC_OUT         0x40000000      /* copy out parameters */
00164 #define IOC_IN          0x80000000      /* copy in parameters */
00165 #define IOC_INOUT       (IOC_IN|IOC_OUT)
00166                                         /* 0x20000000 distinguishes new &
00167                                            old ioctl's */
00168 #define _IO(x,y)        (IOC_VOID|(x<<8)|y)
00169 
00170 #define _IOR(x,y,t)     (IOC_OUT|(((long)sizeof(t)&IOCPARM_MASK)<<16)|(x<<8)|y)
00171 
00172 #define _IOW(x,y,t)     (IOC_IN|(((long)sizeof(t)&IOCPARM_MASK)<<16)|(x<<8)|y)
00173 
00174 #define FIONREAD    _IOR('f', 127, u_long) /* get # bytes to read */
00175 #define FIONBIO     _IOW('f', 126, u_long) /* set/clear non-blocking i/o */
00176 #define FIOASYNC    _IOW('f', 125, u_long) /* set/clear async i/o */
00177 
00178 /* Socket I/O Controls */
00179 #define SIOCSHIWAT  _IOW('s',  0, u_long)  /* set high watermark */
00180 #define SIOCGHIWAT  _IOR('s',  1, u_long)  /* get high watermark */
00181 #define SIOCSLOWAT  _IOW('s',  2, u_long)  /* set low watermark */
00182 #define SIOCGLOWAT  _IOR('s',  3, u_long)  /* get low watermark */
00183 #define SIOCATMARK  _IOR('s',  7, u_long)  /* at oob mark? */
00184 
00185 /*
00186  * Structures returned by network data base library, taken from the
00187  * BSD file netdb.h.  All addresses are supplied in host order, and
00188  * returned in network order (suitable for use in system calls).
00189  */
00190 
00191 struct hostent
00192 {
00193    char  *h_name;       /* official name of host */
00194    char  **h_aliases;      /* alias list */
00195    short h_addrtype;       /* host address type */
00196    short h_length;         /* length of address */
00197    char  **h_addr_list;    /* list of addresses */
00198 #define h_addr  h_addr_list[0]   /* address, for backward compat */
00199 };
00200 
00201 /*
00202  * It is assumed here that a network number fits in 32 bits.
00203  */
00204 struct netent
00205 {
00206    char  *n_name;    /* official name of net */
00207    char  **n_aliases;   /* alias list */
00208    short n_addrtype;    /* net address type */
00209    u_long   n_net;         /* network # */
00210 };
00211 
00212 struct servent
00213 {
00214    char  *s_name;       /* official service name */
00215    char  **s_aliases;  /* alias list */
00216    short   s_port;             /* port # */
00217    char  *s_proto;         /* protocol to use */
00218 };
00219 
00220 struct protoent
00221 {
00222    char  *p_name;    /* official protocol name */
00223    char  **p_aliases;   /* alias list */
00224    short   p_proto;     /* protocol # */
00225 };
00226 
00227 /*
00228  * Constants and structures defined by the internet system,
00229  * Per RFC 790, September 1981, taken from the BSD file netinet/in.h.
00230  */
00231 
00232 /*
00233  * Protocols
00234  */
00235 #define IPPROTO_IP         0     /* dummy for IP */
00236 #define IPPROTO_ICMP    1     /* control message protocol */
00237 #define IPPROTO_GGP        2     /* gateway^2 (deprecated) */
00238 #define IPPROTO_TCP        6     /* tcp */
00239 #define IPPROTO_PUP        12    /* pup */
00240 #define IPPROTO_UDP        17    /* user datagram protocol */
00241 #define IPPROTO_IDP        22    /* xns idp */
00242 #define IPPROTO_ND         77    /* UNOFFICIAL net disk proto */
00243 
00244 #define IPPROTO_RAW        255      /* raw IP packet */
00245 #define IPPROTO_MAX        256
00246 
00247 /*
00248  * Port/socket numbers: network standard functions
00249  */
00250 #define IPPORT_ECHO        7
00251 #define IPPORT_DISCARD     9
00252 #define IPPORT_SYSTAT      11
00253 #define IPPORT_DAYTIME     13
00254 #define IPPORT_NETSTAT     15
00255 #define IPPORT_FTP         21
00256 #define IPPORT_TELNET      23
00257 #define IPPORT_SMTP        25
00258 #define IPPORT_TIMESERVER  37
00259 #define IPPORT_NAMESERVER  42
00260 #define IPPORT_WHOIS    43
00261 #define IPPORT_MTP         57
00262 
00263 /*
00264  * Port/socket numbers: host specific functions
00265  */
00266 #define IPPORT_TFTP        69
00267 #define IPPORT_RJE         77
00268 #define IPPORT_FINGER      79
00269 #define IPPORT_TTYLINK     87
00270 #define IPPORT_SUPDUP      95
00271 
00272 /*
00273  * UNIX TCP sockets
00274  */
00275 #define IPPORT_EXECSERVER  512
00276 #define IPPORT_LOGINSERVER 513
00277 #define IPPORT_CMDSERVER   514
00278 #define IPPORT_EFSSERVER   520
00279 
00280 /*
00281  * UNIX UDP sockets
00282  */
00283 #define IPPORT_BIFFUDP     512
00284 #define IPPORT_WHOSERVER   513
00285 #define IPPORT_ROUTESERVER 520
00286                               /* 520+1 also used */
00287 
00288 /*
00289  * Ports < IPPORT_RESERVED are reserved for
00290  * privileged processes (e.g. root).
00291  */
00292 #define IPPORT_RESERVED    1024
00293 
00294 /*
00295  * Link numbers
00296  */
00297 #define IMPLINK_IP         155
00298 #define IMPLINK_LOWEXPER   156
00299 #define IMPLINK_HIGHEXPER  158
00300 
00301 /*
00302  * Internet address (old style... should be updated)
00303  */
00304 struct in_addr
00305 {
00306    union
00307    {
00308       struct { u_char s_b1, s_b2, s_b3, s_b4; } S_un_b;
00309       struct { u_short s_w1, s_w2; } S_un_w;
00310       u_long S_addr;
00311    } S_un;
00312 
00313 #define s_addr  S_un.S_addr
00314                         /* can be used for most tcp & ip code */
00315 #define s_host  S_un.S_un_b.s_b2
00316                         /* host on imp */
00317 #define s_net   S_un.S_un_b.s_b1
00318                         /* network */
00319 #define s_imp   S_un.S_un_w.s_w2
00320                         /* imp */
00321 #define s_impno S_un.S_un_b.s_b4
00322                         /* imp # */
00323 #define s_lh   S_un.S_un_b.s_b3
00324                         /* logical host */
00325 };
00326 
00327 /*
00328  * Definitions of bits in internet address integers.
00329  * On subnets, the decomposition of addresses to host and net parts
00330  * is done according to subnet mask, not the masks here.
00331  */
00332 #define IN_CLASSA(i)       (((long)(i) & 0x80000000) == 0)
00333 #define IN_CLASSA_NET         0xff000000
00334 #define IN_CLASSA_NSHIFT      24
00335 #define IN_CLASSA_HOST        0x00ffffff
00336 #define IN_CLASSA_MAX         128
00337 
00338 #define IN_CLASSB(i)       (((long)(i) & 0xc0000000) == 0x80000000)
00339 #define IN_CLASSB_NET         0xffff0000
00340 #define IN_CLASSB_NSHIFT      16
00341 #define IN_CLASSB_HOST        0x0000ffff
00342 #define IN_CLASSB_MAX         65536
00343 
00344 #define IN_CLASSC(i)       (((long)(i) & 0xc0000000) == 0xc0000000)
00345 #define IN_CLASSC_NET         0xffffff00
00346 #define IN_CLASSC_NSHIFT      8
00347 #define IN_CLASSC_HOST        0x000000ff
00348 
00349 #define INADDR_ANY            (u_long)0x00000000
00350 #define INADDR_LOOPBACK       0x7f000001
00351 #define INADDR_BROADCAST      (u_long)0xffffffff   
00352 #define INADDR_NONE           0xffffffff
00353 
00354 /*
00355  * Socket address, internet style.
00356  */
00357 struct sockaddr_in
00358 {
00359    short       sin_family;
00360    u_short        sin_port;
00361    struct in_addr sin_addr;
00362    char        sin_zero[8];
00363 };
00364 
00365 #define WSADESCRIPTION_LEN 256
00366 #define WSASYS_STATUS_LEN  128
00367 
00368 typedef struct WSAData
00369 {
00370    u_short     wVersion;
00371    u_short     wHighVersion;
00372    char     szDescription[WSADESCRIPTION_LEN+1];
00373    char     szSystemStatus[WSASYS_STATUS_LEN+1];
00374    u_short     iMaxSockets;
00375    u_short     iMaxUdpDg;
00376    char     *lpVendorInfo;
00377 } WSADATA;
00378 
00379 typedef WSADATA *LPWSADATA;
00380 
00381 /*
00382  * Options for use with [gs]etsockopt at the IP level.
00383  */
00384 #ifndef IP_OPTIONS
00385 #define IP_OPTIONS   1           /* set/get IP per-packet options */
00386 #endif
00387 
00388 /*
00389  * Multicast support
00390  */
00391 #ifndef IP_TOS
00392    #define  IP_TOS               0x02
00393    #define  IP_TTL               0x03
00394    #define  IP_MULTICAST_IF         0x1010   /* set/get IP multicast interface   */
00395    #define  IP_MULTICAST_TTL     0x1011   /* set/get IP multicast timetolive  */
00396    #define  IP_MULTICAST_LOOP    0x1012   /* set/get IP multicast loopback */
00397    #define  IP_ADD_MEMBERSHIP    0x1013   /* add an IP group membership    */
00398    #define  IP_DROP_MEMBERSHIP      0x1014   /* drop an IP group membership      */
00399 #endif
00400 #define IP_DONTFRAGMENT          0x09  /* set/get IP Don't Fragment flag   */
00401 
00402 /*
00403  * More multicast stuff
00404  */
00405 #define IP_DEFAULT_MULTICAST_TTL   1      /* normally limit m'casts to 1 hop  */
00406 #define IP_DEFAULT_MULTICAST_LOOP  1      /* normally hear sends if a member  */
00407 #define IP_MAX_MEMBERSHIPS         20     /* per socket; must fit in one mbuf */
00408 
00409 /*
00410  * Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP.
00411  */
00412 struct ip_mreq {
00413    struct in_addr  imr_multiaddr;  /* IP multicast address of group */
00414    struct in_addr  imr_interface;  /* local IP address of interface */
00415 };
00416 
00417 /*
00418  * Definitions related to sockets: types, address families, options,
00419  * taken from the BSD file sys/socket.h.
00420  */
00421 
00422 /*
00423  * This is used instead of -1, since the
00424  * SOCKET type is unsigned.
00425  */
00426 #define INVALID_SOCKET  (SOCKET)(~0)
00427 #define SOCKET_ERROR (-1)
00428 
00429 /*
00430  * Types
00431  */
00432 #define SOCK_STREAM     1           /* stream socket */
00433 #define SOCK_DGRAM      2           /* datagram socket */
00434 #define SOCK_RAW     3           /* raw-protocol interface */
00435 #define SOCK_RDM     4           /* reliably-delivered message */
00436 #define SOCK_SEQPACKET  5           /* sequenced packet stream */
00437 
00438 /*
00439  * Option flags per-socket.
00440  */
00441 #define SO_DEBUG     0x0001        /* turn on debugging info recording */
00442 #define SO_ACCEPTCONN   0x0002        /* socket has had listen() */
00443 #define SO_REUSEADDR 0x0004        /* allow local address reuse */
00444 #define SO_KEEPALIVE 0x0008        /* keep connections alive */
00445 #define SO_DONTROUTE 0x0010        /* just use interface addresses */
00446 #define SO_BROADCAST 0x0020        /* permit sending of broadcast msgs */
00447 #define SO_USELOOPBACK  0x0040        /* bypass hardware when possible */
00448 #define SO_LINGER    0x0080        /* linger on close if data present */
00449 #define SO_OOBINLINE 0x0100        /* leave received OOB data in line */
00450 
00451 #define SO_DONTLINGER   (u_int)(~SO_LINGER)
00452 
00453 /*
00454  * Additional options.
00455  */
00456 #define SO_SNDBUF    0x1001        /* send buffer size */
00457 #define SO_RCVBUF    0x1002        /* receive buffer size */
00458 #define SO_SNDLOWAT     0x1003        /* send low-water mark */
00459 #define SO_RCVLOWAT     0x1004        /* receive low-water mark */
00460 #define SO_SNDTIMEO     0x1005        /* send timeout */
00461 #define SO_RCVTIMEO     0x1006        /* receive timeout */
00462 #define SO_ERROR     0x1007        /* get error status and clear */
00463 #define SO_TYPE         0x1008        /* get socket type */
00464 
00465 /*
00466  * TCP options.
00467  */
00468 #ifndef TCP_NODELAY
00469 #define TCP_NODELAY     0x0001
00470 #endif
00471 
00472 /*
00473  * Address families.
00474  */
00475 #define AF_UNSPEC    0        /* unspecified */
00476 #define AF_UNIX         1        /* local to host (pipes, portals) */
00477 #define AF_INET         2        /* internetwork: UDP, TCP, etc. */
00478 #define AF_IMPLINK      3        /* arpanet imp addresses */
00479 #define AF_PUP       4        /* pup protocols: e.g. BSP */
00480 #define AF_CHAOS     5        /* mit CHAOS protocols */
00481 #define AF_NS        6        /* XEROX NS protocols */
00482 #define AF_ISO       7        /* ISO protocols */
00483 #define AF_OSI       AF_ISO      /* OSI is ISO */
00484 #define AF_ECMA         8        /* european computer manufacturers */
00485 #define AF_DATAKIT      9        /* datakit protocols */
00486 #define AF_CCITT     10       /* CCITT protocols, X.25 etc */
00487 #define AF_SNA       11       /* IBM SNA */
00488 #define AF_DECnet    12       /* DECnet */
00489 #define AF_DLI       13       /* Direct data link interface */
00490 #define AF_LAT       14       /* LAT */
00491 #define AF_HYLINK    15       /* NSC Hyperchannel */
00492 #define AF_APPLETALK 16       /* AppleTalk */
00493 #define AF_NETBIOS      17       /* NetBios-style addresses */
00494 
00495 #define AF_MAX       18
00496 
00497 /*
00498  * Structure used by kernel to store most
00499  * addresses.
00500  */
00501 struct sockaddr
00502 {
00503    u_short sa_family;      /* address family */
00504    char  sa_data[14];   /* up to 14 bytes of direct address */
00505 };
00506 
00507 /*
00508  * Structure used by kernel to pass protocol
00509  * information in raw sockets.
00510  */
00511 struct sockproto
00512 {
00513    u_short sp_family;      /* address family */
00514    u_short sp_protocol; /* protocol */
00515 };
00516 
00517 /*
00518  * Protocol families, same as address families for now.
00519  */
00520 #define PF_UNSPEC    AF_UNSPEC
00521 #define PF_UNIX         AF_UNIX
00522 #define PF_INET         AF_INET
00523 #define PF_IMPLINK      AF_IMPLINK
00524 #define PF_PUP       AF_PUP
00525 #define PF_CHAOS     AF_CHAOS
00526 #define PF_NS        AF_NS
00527 #define PF_ISO       AF_ISO
00528 #define PF_OSI       AF_OSI
00529 #define PF_ECMA         AF_ECMA
00530 #define PF_DATAKIT      AF_DATAKIT
00531 #define PF_CCITT     AF_CCITT
00532 #define PF_SNA       AF_SNA
00533 #define PF_DECnet    AF_DECnet
00534 #define PF_DLI       AF_DLI
00535 #define PF_LAT       AF_LAT
00536 #define PF_HYLINK    AF_HYLINK
00537 #define PF_APPLETALK AF_APPLETALK
00538 
00539 #define PF_MAX       AF_MAX
00540 
00541 /*
00542  * Structure used for manipulating linger option.
00543  */
00544 struct linger
00545 {
00546    u_short l_onoff;  /* option on/off */
00547    u_short l_linger; /* linger time */
00548 };
00549 
00550 /*
00551  * Level number for (get/set)sockopt() to apply to socket itself.
00552  */
00553 #define SOL_SOCKET      0xffff        /* options for socket level */
00554 
00555 /*
00556  * Maximum queue length specifiable by listen.
00557  */
00558 #define SOMAXCONN    5
00559 
00560 #define MSG_OOB         0x1          /* process out-of-band data */
00561 #define MSG_PEEK     0x2          /* peek at incoming message */
00562 #define MSG_DONTROUTE   0x4          /* send without using routing tables */
00563 
00564 #define MSG_MAXIOVLEN   16
00565 
00566 /*
00567  * Define constant based on rfc883, used by gethostbyxxxx() calls.
00568  */
00569 #define MAXGETHOSTSTRUCT      1024
00570 
00571 /*
00572  * Define flags to be used with the WSAAsyncSelect() call.
00573  */
00574 #define FD_READ      0x01
00575 #define FD_WRITE  0x02
00576 #define FD_OOB    0x04
00577 #define FD_ACCEPT 0x08
00578 #define FD_CONNECT   0x10
00579 #define FD_CLOSE  0x20
00580 
00581 /*
00582  * All Windows Sockets error constants are biased by WSABASEERR from
00583  * the "normal"
00584  */
00585 #define WSABASEERR           10000
00586 
00587 /*
00588  * Windows Sockets definitions of regular Microsoft C error constants
00589  */
00590 #define WSAEINTR           (WSABASEERR+4)
00591 #define WSAEBADF           (WSABASEERR+9)
00592 #define WSAEACCES          (WSABASEERR+13)
00593 #define WSAEFAULT          (WSABASEERR+14)
00594 #define WSAEINVAL          (WSABASEERR+22)
00595 #define WSAEMFILE          (WSABASEERR+24)
00596 
00597 /*
00598  * Windows Sockets definitions of regular Berkeley error constants
00599  */
00600 #define WSAEWOULDBLOCK     (WSABASEERR+35)
00601 #define WSAEINPROGRESS     (WSABASEERR+36)
00602 #define WSAEALREADY        (WSABASEERR+37)
00603 #define WSAENOTSOCK        (WSABASEERR+38)
00604 #define WSAEDESTADDRREQ    (WSABASEERR+39)
00605 #define WSAEMSGSIZE        (WSABASEERR+40)
00606 #define WSAEPROTOTYPE      (WSABASEERR+41)
00607 #define WSAENOPROTOOPT     (WSABASEERR+42)
00608 #define WSAEPROTONOSUPPORT (WSABASEERR+43)
00609 #define WSAESOCKTNOSUPPORT (WSABASEERR+44)
00610 #define WSAEOPNOTSUPP      (WSABASEERR+45)
00611 #define WSAEPFNOSUPPORT    (WSABASEERR+46)
00612 #define WSAEAFNOSUPPORT    (WSABASEERR+47)
00613 #define WSAEADDRINUSE      (WSABASEERR+48)
00614 #define WSAEADDRNOTAVAIL   (WSABASEERR+49)
00615 #define WSAENETDOWN        (WSABASEERR+50)
00616 #define WSAENETUNREACH     (WSABASEERR+51)
00617 #define WSAENETRESET    (WSABASEERR+52)
00618 #define WSAECONNABORTED    (WSABASEERR+53)
00619 #define WSAECONNRESET      (WSABASEERR+54)
00620 #define WSAENOBUFS         (WSABASEERR+55)
00621 #define WSAEISCONN         (WSABASEERR+56)
00622 #define WSAENOTCONN        (WSABASEERR+57)
00623 #define WSAESHUTDOWN    (WSABASEERR+58)
00624 #define WSAETOOMANYREFS    (WSABASEERR+59)
00625 #define WSAETIMEDOUT    (WSABASEERR+60)
00626 #define WSAECONNREFUSED    (WSABASEERR+61)
00627 #define WSAELOOP        (WSABASEERR+62)
00628 #define WSAENAMETOOLONG    (WSABASEERR+63)
00629 #define WSAEHOSTDOWN    (WSABASEERR+64)
00630 #define WSAEHOSTUNREACH    (WSABASEERR+65)
00631 #define WSAENOTEMPTY    (WSABASEERR+66)
00632 #define WSAEPROCLIM        (WSABASEERR+67)
00633 #define WSAEUSERS       (WSABASEERR+68)
00634 #define WSAEDQUOT       (WSABASEERR+69)
00635 #define WSAESTALE       (WSABASEERR+70)
00636 #define WSAEREMOTE         (WSABASEERR+71)
00637 
00638 /*
00639  * Extended Windows Sockets error constant definitions
00640  */
00641 #define WSASYSNOTREADY     (WSABASEERR+91)
00642 #define WSAVERNOTSUPPORTED (WSABASEERR+92)
00643 #define WSANOTINITIALISED  (WSABASEERR+93)
00644 
00645 /*
00646  * Error return codes from gethostbyname() and gethostbyaddr()
00647  * (when using the resolver). Note that these errors are
00648  * retrieved via WSAGetLastError() and must therefore follow
00649  * the rules for avoiding clashes with error numbers from
00650  * specific implementations or language run-time systems.
00651  * For this reason the codes are based at WSABASEERR+1001.
00652  * Note also that [WSA]NO_ADDRESS is defined only for
00653  * compatibility purposes.
00654  */
00655 
00656 #define h_errno       WSAGetLastError()
00657 
00658 /* Authoritative Answer: Host not found */
00659 #define WSAHOST_NOT_FOUND  (WSABASEERR+1001)
00660 #define HOST_NOT_FOUND     WSAHOST_NOT_FOUND
00661 
00662 /* Non-Authoritative: Host not found, or SERVERFAIL */
00663 #define WSATRY_AGAIN    (WSABASEERR+1002)
00664 #define TRY_AGAIN       WSATRY_AGAIN
00665 
00666 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
00667 #define WSANO_RECOVERY     (WSABASEERR+1003)
00668 #define NO_RECOVERY        WSANO_RECOVERY
00669 
00670 /* Valid name, no data record of requested type */
00671 #define WSANO_DATA         (WSABASEERR+1004)
00672 #define NO_DATA            WSANO_DATA
00673 
00674 /* no address, look for MX record */
00675 #define WSANO_ADDRESS      WSANO_DATA
00676 #define NO_ADDRESS         WSANO_ADDRESS
00677 
00678 /*
00679  * Windows Sockets errors redefined as regular Berkeley error constants
00680  */
00681 #define EWOULDBLOCK        WSAEWOULDBLOCK
00682 #define EINPROGRESS        WSAEINPROGRESS
00683 #define EALREADY        WSAEALREADY
00684 #define ENOTSOCK        WSAENOTSOCK
00685 #define EDESTADDRREQ    WSAEDESTADDRREQ
00686 #define EMSGSIZE        WSAEMSGSIZE
00687 #define EPROTOTYPE         WSAEPROTOTYPE
00688 #define ENOPROTOOPT        WSAENOPROTOOPT
00689 #define EPROTONOSUPPORT    WSAEPROTONOSUPPORT
00690 #define ESOCKTNOSUPPORT    WSAESOCKTNOSUPPORT
00691 #define EOPNOTSUPP         WSAEOPNOTSUPP
00692 #define EPFNOSUPPORT    WSAEPFNOSUPPORT
00693 #define EAFNOSUPPORT    WSAEAFNOSUPPORT
00694 #define EADDRINUSE         WSAEADDRINUSE
00695 #define EADDRNOTAVAIL      WSAEADDRNOTAVAIL
00696 #define ENETDOWN        WSAENETDOWN
00697 #define ENETUNREACH        WSAENETUNREACH
00698 #define ENETRESET       WSAENETRESET
00699 #define ECONNABORTED    WSAECONNABORTED
00700 #define ECONNRESET         WSAECONNRESET
00701 #define ENOBUFS            WSAENOBUFS
00702 #define EISCONN            WSAEISCONN
00703 #define ENOTCONN        WSAENOTCONN
00704 #define ESHUTDOWN       WSAESHUTDOWN
00705 #define ETOOMANYREFS    WSAETOOMANYREFS
00706 #define ETIMEDOUT       WSAETIMEDOUT
00707 #define ECONNREFUSED    WSAECONNREFUSED
00708 #define ELOOP           WSAELOOP
00709 #define ENAMETOOLONG    WSAENAMETOOLONG
00710 #define EHOSTDOWN       WSAEHOSTDOWN
00711 #define EHOSTUNREACH    WSAEHOSTUNREACH
00712 #define ENOTEMPTY       WSAENOTEMPTY
00713 #define EPROCLIM        WSAEPROCLIM
00714 #define EUSERS          WSAEUSERS
00715 #define EDQUOT          WSAEDQUOT
00716 #define ESTALE          WSAESTALE
00717 #define EREMOTE            WSAEREMOTE
00718 
00719 /* Macintosh specific definitions   */
00720 
00721 /* Macintosh host ordering is the same as network ordering  */
00722 #define htonl(hostlong)    ((u_long)(hostlong))
00723 #define htons(hostshort)   ((u_short)(hostshort))
00724 #define ntohl(netlong)     ((u_long)(netlong))
00725 #define ntohs(netshort)    ((u_short)(netshort))
00726 
00727 typedef pascal long (*WSABlockingHookProcPtr)( void );
00728 
00729 enum
00730 {
00731    uppWSABlockingHookInfo = kPascalStackBased
00732       | RESULT_SIZE( SIZE_CODE( sizeof( long ) ) )
00733 };
00734 
00735 /*
00736 #if GENERATINGCFM
00737 
00738 typedef UniversalProcPtr WSABlockingHookUPP;
00739 
00740 #define NewWSABlockingHookProc(userRoutine)  \
00741    (WSABlockingHookUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppWSABlockingHookInfo, GetCurrentArchitecture())
00742 
00743 #define CallWSABlockingHookProc(userRoutine) \
00744    CallUniversalProc((UniversalProcPtr)(userRoutine), uppWSABlockingHookInfo)
00745 
00746 #else
00747 */
00748 typedef WSABlockingHookProcPtr WSABlockingHookUPP;
00749 
00750 #define NewWSABlockingHookProc(userRoutine)  \
00751    ((WSABlockingHookUPP) (userRoutine))
00752 
00753 #define CallWSABlockingHookProc(userRoutine) \
00754    (*(userRoutine))()
00755 
00756 //#endif
00757 
00758 #ifdef __cplusplus
00759 extern "C" {
00760 #endif
00761 
00762 /* Socket function prototypes */
00763 
00764 pascal SOCKET  accept( SOCKET s, struct sockaddr *addr, int *addrlen );
00765 pascal int     bind( SOCKET s, struct sockaddr *addr, int namelen );
00766 pascal int     closesocket( SOCKET s );
00767 pascal int     connect( SOCKET s, struct sockaddr *name, int namelen );
00768 pascal int     ioctlsocket( SOCKET s, long cmd, u_long *argp );
00769 pascal int     getpeername( SOCKET s, struct sockaddr *name, int *namelen );
00770 pascal int     getsockname( SOCKET s, struct sockaddr *name, int *namelen );
00771 pascal int     getsockopt( SOCKET s, int level, int optname, char *optval, int *optlen );
00772 pascal u_long  inet_addr( char *cp );
00773 pascal char *  inet_ntoa( struct in_addr in );
00774 pascal int     listen( SOCKET s, int backlog );
00775 pascal int     recv( SOCKET s, char *buf, int len, int flags );
00776 pascal int     recvfrom( SOCKET s, char *buf, int len, int flags, struct sockaddr *from, int *fromlen );
00777 pascal int     select( int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout );
00778 pascal int     send( SOCKET s, char *buf, int len, int flags );
00779 pascal int     sendto( SOCKET s, char *buf, int len, int flags, struct sockaddr *to, int tolen );
00780 pascal int     setsockopt( SOCKET s, int level, int optname, char *optval, int optlen );
00781 pascal int     shutdown( SOCKET s, int how );
00782 pascal SOCKET  socket( int af, int type, int protocol );
00783 
00784 /* Database function prototypes */
00785 
00786 pascal struct hostent *    gethostbyaddr( char *addr, int len, int type );
00787 pascal struct hostent *    gethostbyname( char *name );
00788 pascal int              gethostname( char *name, int namelen );
00789 pascal struct servent *    getservbyport( int port, char *proto );
00790 pascal struct servent *    getservbyname( char *name, char *proto );
00791 pascal struct protoent *   getprotobynumber( int proto );
00792 pascal struct protoent *   getprotobyname( char *name );
00793 
00794 /* Microsoft Windows Extension function prototypes */
00795 
00796 pascal int WSAStartup( u_short wVersionRequired, LPWSADATA lpWSAData );
00797 pascal int WSACleanup( void );
00798 
00799 pascal void WSASetLastError( int iError );
00800 pascal int WSAGetLastError( void );
00801 
00802 pascal int WSAIsBlocking( void );
00803 pascal int WSAUnhookBlockingHook( void );
00804 
00805 pascal WSABlockingHookUPP WSASetBlockingHook( WSABlockingHookUPP pprocHook );
00806 pascal int WSACancelBlockingCall( void );
00807 
00808 pascal HANDLE WSAAsyncGetServByName( NMMessageHandler hWnd, u_int wMsg, char *name, char *proto, char *buf, int buflen );
00809 pascal HANDLE WSAAsyncGetServByPort( NMMessageHandler hWnd, u_int wMsg, int port, char *proto, char *buf, int buflen );
00810 pascal HANDLE WSAAsyncGetProtoByName( NMMessageHandler hWnd, u_int wMsg, char *name, char *buf, int buflen );
00811 pascal HANDLE WSAAsyncGetProtoByNumber( NMMessageHandler hWnd, u_int wMsg, int number, char *buf, int buflen );
00812 pascal HANDLE WSAAsyncGetHostByName( NMMessageHandler hWnd, u_int wMsg, char *name, char *buf, int buflen );
00813 pascal HANDLE WSAAsyncGetHostByAddr( NMMessageHandler hWnd, u_int wMsg, char *addr, int len, int type, char *buf, int buflen );
00814 
00815 pascal int WSACancelAsyncRequest( HANDLE lAsyncTaskID );
00816 
00817 pascal int WSAAsyncSelect( SOCKET s, NMMessageHandler hWnd, u_int wMsg, long lEvent );
00818 
00819 #ifdef __cplusplus
00820 }
00821 #endif
00822 
00823 /* Microsoft Windows Extended data types */
00824 typedef struct sockaddr SOCKADDR;
00825 typedef struct sockaddr *PSOCKADDR;
00826 typedef struct sockaddr *LPSOCKADDR;
00827 
00828 typedef struct sockaddr_in SOCKADDR_IN;
00829 typedef struct sockaddr_in *PSOCKADDR_IN;
00830 typedef struct sockaddr_in *LPSOCKADDR_IN;
00831 
00832 typedef struct linger LINGER;
00833 typedef struct linger *PLINGER;
00834 typedef struct linger *LPLINGER;
00835 
00836 typedef struct in_addr IN_ADDR;
00837 typedef struct in_addr *PIN_ADDR;
00838 typedef struct in_addr *LPIN_ADDR;
00839 
00840 typedef struct fd_set FD_SET;
00841 typedef struct fd_set *PFD_SET;
00842 typedef struct fd_set *LPFD_SET;
00843 
00844 typedef struct hostent HOSTENT;
00845 typedef struct hostent *PHOSTENT;
00846 typedef struct hostent *LPHOSTENT;
00847 
00848 typedef struct servent SERVENT;
00849 typedef struct servent *PSERVENT;
00850 typedef struct servent *LPSERVENT;
00851 
00852 typedef struct protoent PROTOENT;
00853 typedef struct protoent *PPROTOENT;
00854 typedef struct protoent *LPPROTOENT;
00855 
00856 typedef struct timeval TIMEVAL;
00857 typedef struct timeval *PTIMEVAL;
00858 typedef struct timeval *LPTIMEVAL;
00859 
00860 /*
00861  * Windows message parameter composition and decomposition
00862  * macros.
00863  *
00864  * WSAMAKEASYNCREPLY is intended for use by the Windows Sockets implementation
00865  * when constructing the response to a WSAAsyncGetXByY() routine.
00866  */
00867 #define WSAMAKEASYNCREPLY(buflen,error)   MAKELONG(buflen,error)
00868 /*
00869  * WSAMAKESELECTREPLY is intended for use by the Windows Sockets implementation
00870  * when constructing the response to WSAAsyncSelect().
00871  */
00872 #define WSAMAKESELECTREPLY(event,error)   MAKELONG(event,error)
00873 /*
00874  * WSAGETASYNCBUFLEN is intended for use by the Windows Sockets application
00875  * to extract the buffer length from the lParam in the response
00876  * to a WSAGetXByY().
00877  */
00878 #define WSAGETASYNCBUFLEN(luParam)     LOWORD(luParam)
00879 /*
00880  * WSAGETASYNCERROR is intended for use by the Windows Sockets application
00881  * to extract the error code from the lParam in the response
00882  * to a WSAGetXByY().
00883  */
00884 #define WSAGETASYNCERROR(luParam)      HIWORD(luParam)
00885 /*
00886  * WSAGETSELECTEVENT is intended for use by the Windows Sockets application
00887  * to extract the event code from the lParam in the response
00888  * to a WSAAsyncSelect().
00889  */
00890 #define WSAGETSELECTEVENT(luParam)     LOWORD(luParam)
00891 /*
00892  * WSAGETSELECTERROR is intended for use by the Windows Sockets application
00893  * to extract the error code from the lParam in the response
00894  * to a WSAAsyncSelect().
00895  */
00896 #define WSAGETSELECTERROR(luParam)     HIWORD(luParam)
00897 
00898 #endif  /* _WINSOCKAPI_ */

This A:M SDK v12.0 documentation is maintained by Hash Inc. Please address any comments concerning this documentation to AMReports. If you have any information, knowledge, or documentation to share with the A:M developer community, please post them on the Hash SDK forum.

Generated on Thu Oct 27 11:46:44 2005 with doxygen 1.4.5 written by Dimitri van Heesch, © 1997-2001