home *** CD-ROM | disk | FTP | other *** search
/ Super Net 1 / SUPERNET_1.iso / PC / OTROS / MSDOS / WATTCP / MSWATTCP.ZIP / INCLUDE / SOCKET.H < prev    next >
Encoding:
C/C++ Source or Header  |  1993-08-27  |  2.4 KB  |  96 lines

  1. /***********************************************************************
  2.  *
  3.  * File: socket.h
  4.  *
  5.  * created: 05-Jul-93 fr
  6.  */
  7.  
  8. #define u_short    unsigned short
  9. #define u_long    unsigned long
  10. #define u_char    unsigned char
  11. #define u_int    unsigned int
  12.  
  13.  
  14.  
  15. #define AF_INET      2
  16. #define INADDR_ANY   0L
  17. #define SOCK_STREAM  1
  18. #define SOCK_DGRAM   2
  19. #define IPPROTO_IP   0
  20. #define IPPROTO_ICMP 1
  21. #define IPPROTO_UDP  17
  22. #define IPPROTO_TCP  6
  23. #define MAXSOCK      32
  24. #define MAXFILE      32
  25.  
  26. /*typedef struct sockdesc{
  27.     int        valid;
  28.     int        type;
  29.     int         my_port;
  30.     sock_type    *sockp;
  31.     } sock_desc; this is in tcp.h */
  32.  
  33.  
  34. struct sockaddr{
  35.     u_short        sa_family;
  36.     char        sa_data[14];
  37.     };
  38.  
  39. struct in_addr{
  40.     u_long        s_addr;
  41.     };
  42.  
  43. struct sockaddr_in {
  44.     short        sin_family;
  45.     u_short        sin_port;
  46.     struct in_addr    sin_addr;
  47.     char        sin_zero[8];
  48.     };
  49.  
  50. struct hostent {
  51.     char    *h_name;         /* host name */
  52.     char    **h_aliases;    /* list of host name aliases */
  53.     int    h_addrtype;     /* this is always AF_INET for us */
  54.     int     h_length;    /* this is always 4 for us */
  55.     char     **h_addr_list;    /* these are pointers to in_addr struct */
  56.     };
  57. #define h_addr     h_addr_list[0]
  58.  
  59. #define bcopy(src, dst, nbytes)     memcpy(dst, src, nbytes)
  60. #define bzero(dst, nbytes)         memset(dst, 0, nbytes)
  61. #define bcmp(ptr1, ptr2, nbytes)     strncmp(ptr1, ptr2, nbytes)
  62.  
  63. #define    NBBY    8        /* number of bits in a byte */
  64. /*
  65.  * Select uses bit masks of file descriptors in longs.
  66.  * These macros manipulate such bit fields (the filesystem macros use chars).
  67.  */
  68. #ifndef    FD_SETSIZE
  69. #define    FD_SETSIZE    64
  70. #endif    /* FD_SETSIZE */
  71.  
  72. /* How many things we'll allow select to use. 0 if unlimited */
  73. #define MAXSELFD    64
  74. typedef long    fd_mask;
  75. #define NFDBITS    (sizeof(fd_mask) * NBBY)    /* bits per mask (power of 2!)*/
  76. #define NFDSHIFT 5                /* Shift based on above */
  77. #ifndef howmany
  78. #define    howmany(x, y)    (((x)+((y)-1))/(y))
  79. #endif /* howmany */
  80.  
  81. typedef    struct fd_set {
  82.     fd_mask    fds_bits[howmany(FD_SETSIZE, NFDBITS)];
  83.     } fd_set;
  84.  
  85. #define    FD_SET(n, p)    ((p)->fds_bits[(n)/NFDBITS] |= ((long)1 << ((n) % NFDBITS)))
  86. #define    FD_CLR(n, p)    ((p)->fds_bits[(n)/NFDBITS] &= ~((long)1 << ((n) % NFDBITS)))
  87. #define    FD_ISSET(n, p)    ((p)->fds_bits[(n)/NFDBITS] & ((long)1 << ((n) % NFDBITS)))
  88. #define FD_ZERO(p)    bzero(p, sizeof(fd_set))
  89. /*#define FD_ZERO(p)    memset(p, 0, sizeof(fd_set))*/
  90.  
  91. struct timeval {
  92.     long    tv_sec;        /* seconds */
  93.     long    tv_usec;    /* microseconds */
  94.     };
  95.  
  96.