home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Entertainment / MacMud / Unix / sys⁄socket.h < prev    next >
Encoding:
Text File  |  1988-01-26  |  3.1 KB  |  113 lines  |  [TEXT/MPS ]

  1. /*    @(#)socket.h 1.1 85/12/18 SMI; from UCB 4.27 83/05/27    */
  2.  
  3. /*
  4.  * Definitions related to sockets: types, address families, options.
  5.  */
  6.  
  7. /*
  8.  * Types
  9.  */
  10. #define    SOCK_STREAM    1        /* stream socket */
  11. #define    SOCK_DGRAM    2        /* datagram socket */
  12. #define    SOCK_RAW    3        /* raw-protocol interface */
  13. #define    SOCK_RDM    4        /* reliably-delivered message */
  14. #define    SOCK_SEQPACKET    5        /* sequenced packet stream */
  15.  
  16. /*
  17.  * Option flags per-socket.
  18.  */
  19. #define    SO_DEBUG    0x01        /* turn on debugging info recording */
  20. #define    SO_ACCEPTCONN    0x02        /* socket has had listen() */
  21. #define    SO_REUSEADDR    0x04        /* allow local address reuse */
  22. #define    SO_KEEPALIVE    0x08        /* keep connections alive */
  23. #define    SO_DONTROUTE    0x10        /* just use interface addresses */
  24.                 /* 0x20 was SO_NEWFDONCONN */
  25. #define    SO_USELOOPBACK    0x40        /* bypass hardware when possible */
  26. #define    SO_LINGER    0x80        /* linger on close if data present */
  27. #define    SO_DONTLINGER    (~SO_LINGER)    /* ~SO_LINGER */
  28.  
  29. /*
  30.  * Address families.
  31.  */
  32. #define    AF_UNSPEC    0        /* unspecified */
  33. #define    AF_UNIX        1        /* local to host (pipes, portals) */
  34. #define    AF_INET        2        /* internetwork: UDP, TCP, etc. */
  35. #define    AF_IMPLINK    3        /* arpanet imp addresses */
  36. #define    AF_PUP        4        /* pup protocols: e.g. BSP */
  37. #define    AF_CHAOS    5        /* mit CHAOS protocols */
  38. #define    AF_NS        6        /* XEROX NS protocols */
  39. #define    AF_NBS        7        /* nbs protocols */
  40. #define    AF_ECMA        8        /* european computer manufacturers */
  41. #define    AF_DATAKIT    9        /* datakit protocols */
  42. #define    AF_CCITT    10        /* CCITT protocols, X.25 etc */
  43. #define    AF_SNA        11        /* IBM SNA */
  44. #define AF_NIT        12        /* Network Interface Tap */
  45.  
  46. #define    AF_MAX        13
  47.  
  48. /*
  49.  * Structure used by kernel to store most
  50.  * addresses.
  51.  */
  52. struct sockaddr {
  53.     u_short    sa_family;        /* address family */
  54.     char    sa_data[14];        /* up to 14 bytes of direct address */
  55. };
  56.  
  57. /*
  58.  * Structure used by kernel to pass protocol
  59.  * information in raw sockets.
  60.  */
  61. struct sockproto {
  62.     u_short    sp_family;        /* address family */
  63.     u_short    sp_protocol;        /* protocol */
  64. };
  65.  
  66. /*
  67.  * Protocol families, same as address families for now.
  68.  */
  69. #define    PF_UNSPEC    AF_UNSPEC
  70. #define    PF_UNIX        AF_UNIX
  71. #define    PF_INET        AF_INET
  72. #define    PF_IMPLINK    AF_IMPLINK
  73. #define    PF_PUP        AF_PUP
  74. #define    PF_CHAOS    AF_CHAOS
  75. #define    PF_NS        AF_NS
  76. #define    PF_NBS        AF_NBS
  77. #define    PF_ECMA        AF_ECMA
  78. #define    PF_DATAKIT    AF_DATAKIT
  79. #define    PF_CCITT    AF_CCITT
  80. #define    PF_SNA        AF_SNA
  81. #define PF_NIT        AF_NIT
  82.  
  83. #define    PF_MAX        13
  84.  
  85. /*
  86.  * Level number for (get/set)sockopt() to apply to socket itself.
  87.  */
  88. #define    SOL_SOCKET    0xffff        /* options for socket level */
  89.  
  90. /*
  91.  * Maximum queue length specifiable by listen.
  92.  */
  93. #define    SOMAXCONN    5
  94.  
  95. /*
  96.  * Message header for recvmsg and sendmsg calls.
  97.  */
  98. struct msghdr {
  99.     caddr_t    msg_name;        /* optional address */
  100.     int    msg_namelen;        /* size of address */
  101.     struct    iovec *msg_iov;        /* scatter/gather array */
  102.     int    msg_iovlen;        /* # elements in msg_iov */
  103.     caddr_t    msg_accrights;        /* access rights sent/received */
  104.     int    msg_accrightslen;
  105. };
  106.  
  107. #define    MSG_OOB        0x1        /* process out-of-band data */
  108. #define    MSG_PEEK    0x2        /* peek at incoming message */
  109. #define    MSG_DONTROUTE    0x4        /* send without using routing tables */
  110.  
  111. #define    MSG_MAXIOVLEN    16
  112.  
  113.