os_socket.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    os_socket.h
00006  *
00007  *  main sockets header
00008  *
00009  *  $Id: os_socket.h 79332 2007-08-13 20:30:44Z sowayaa $
00010  *
00011  *  @author Don Hinton <dhinton@dresystems.com>
00012  *  @author This code was originally in various places including ace/OS.h.
00013  */
00014 //=============================================================================
00015 
00016 #ifndef ACE_OS_INCLUDE_SYS_OS_SOCKET_H
00017 #define ACE_OS_INCLUDE_SYS_OS_SOCKET_H
00018 
00019 #include /**/ "ace/pre.h"
00020 
00021 #include "ace/config-lite.h"
00022 
00023 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00024 # pragma once
00025 #endif /* ACE_LACKS_PRAGMA_ONCE */
00026 
00027 #include "ace/os_include/sys/os_uio.h"
00028 
00029 #if !defined (ACE_LACKS_SYS_SOCKET_H)
00030 #  include /**/ <sys/socket.h>
00031 #endif /* !ACE_LACKS_SYS_SOCKET_H */
00032 
00033 #if defined (ACE_VXWORKS) && (ACE_VXWORKS < 0x620)
00034 #  include /**/ <sockLib.h>
00035 #endif /* ACE_VXWORKS */
00036 
00037 // Place all additions (especially function declarations) within extern "C" {}
00038 #ifdef __cplusplus
00039 extern "C"
00040 {
00041 #endif /* __cplusplus */
00042 
00043 #if !defined (ACE_HAS_MSG) && !defined (SCO)
00044    struct msghdr {};
00045 #endif /* ACE_HAS_MSG */
00046 
00047 #if defined (ACE_HAS_MSG) && defined (ACE_LACKS_MSG_ACCRIGHTS)
00048 #  if !defined (msg_accrights)
00049 #    undef msg_control
00050 #    define msg_accrights msg_control
00051 #  endif /* ! msg_accrights */
00052 
00053 #  if !defined (msg_accrightslen)
00054 #    undef msg_controllen
00055 #    define msg_accrightslen msg_controllen
00056 #  endif /* ! msg_accrightslen */
00057 #endif /* ACE_HAS_MSG && ACE_LACKS_MSG_ACCRIGHTS */
00058 
00059 # if defined (ACE_LACKS_SOCKADDR)
00060     struct sockaddr {
00061             u_char  sa_len;                 /* total length */
00062             u_char  sa_family;              /* address family */
00063             char    sa_data[14];            /* actually longer; address value */
00064     };
00065 # endif /* ACE_LACKS_SOCKADDR */
00066 
00067 # if defined (ACE_LACKS_LINGER)
00068     struct  linger {
00069           int     l_onoff;                /* option on/off */
00070           int     l_linger;               /* linger time */
00071     };
00072 # endif /* ACE_LACKS_LINGER */
00073 
00074 #if defined (ACE_WIN32)
00075    struct msghdr
00076    {
00077      /// Optional address
00078      sockaddr * msg_name;
00079 
00080      /// Size of address
00081      int msg_namelen;
00082 
00083      /// Scatter/gather array
00084      iovec *msg_iov;
00085 
00086      /// # elements in msg_iov
00087      int msg_iovlen;
00088 
00089      /// Access rights sent/received
00090      caddr_t msg_accrights;
00091 
00092      int msg_accrightslen;
00093    };
00094 #endif /* ACE_WIN32 */
00095 
00096 #if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG)
00097    // Control message size to pass a file descriptor.
00098 #  define ACE_BSD_CONTROL_MSG_LEN sizeof (struct cmsghdr) + sizeof (ACE_HANDLE)
00099 #endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */
00100 
00101 // Increase the range of "address families".  Please note that this
00102 // must appear _after_ the include of sys/socket.h, for the AF_FILE
00103 // definition on Linux/glibc2.
00104 #if !defined (AF_ANY)
00105 #  define AF_ANY (-1)
00106 #endif /* AF_ANY */
00107 
00108 #if !defined (AF_UNSPEC)
00109 #  define AF_UNSPEC 0
00110 #endif /* AF_UNSPEC */
00111 
00112 #if !defined (AF_LOCAL)
00113 #  define AF_LOCAL 1
00114 #endif /* AF_LOCAL */
00115 
00116 #if !defined (AF_UNIX)
00117 #  define AF_UNIX AF_LOCAL
00118 #endif /* AF_UNIX */
00119 
00120 #if !defined (AF_INET)
00121 #  define AF_INET 2
00122 #endif /* AF_INET */
00123 
00124 #if !defined (PF_INET)
00125 #  define PF_INET AF_INET
00126 #endif /* PF_INET */
00127 
00128 #if !defined (PF_LOCAL)
00129 #  define PF_LOCAL AF_LOCAL
00130 #endif /* PF_LOCAL */
00131 
00132 #if !defined (PF_UNIX)
00133 #  define PF_UNIX PF_LOCAL
00134 #endif /* PF_UNIX */
00135 
00136 #if !defined (AF_MAX)
00137 #  define AF_MAX 29
00138 #endif /* AF_MAX */
00139 
00140 #if !defined (PF_UNSPEC)
00141 #  define PF_UNSPEC 0
00142 #endif /* PF_UNSPEC */
00143 
00144 #define AF_SPIPE (AF_MAX + 1)
00145 #if !defined (AF_FILE)
00146 #  define AF_FILE (AF_MAX + 2)
00147 #endif /* ! AF_FILE */
00148 #define AF_DEV (AF_MAX + 3)
00149 #define AF_UPIPE (AF_SPIPE)
00150 
00151 #if !defined (MSG_OOB)
00152 #  define MSG_OOB 0x1
00153 #endif /* MSG_OOB */
00154 
00155 #if !defined (MSG_PEEK)
00156 #  define MSG_PEEK 0x2
00157 #endif /* MSG_PEEK */
00158 
00159 #if !defined (SOCK_STREAM)
00160 #  define SOCK_STREAM 1
00161 #endif /* SOCK_STREAM */
00162 
00163 #if !defined (SOCK_DGRAM)
00164 #  define SOCK_DGRAM 2
00165 #endif /* SOCK_DGRAM */
00166 
00167 #if !defined (SOCK_SEQPACKET)
00168 #  define SOCK_SEQPACKET 5
00169 #endif /* SOCK_SEQPACKET */
00170 
00171 #if !defined (SOL_SOCKET)
00172 #  define SOL_SOCKET 0xffff
00173 #endif /* SOL_SOCKET */
00174 
00175 #if !defined (SO_REUSEADDR)
00176 #  define SO_REUSEADDR 0x0004
00177 #endif /* SO_REUSEADDR */
00178 
00179 #if !defined (SO_LINGER)
00180 #  define SO_LINGER 0x0080
00181 #endif /* SO_LINGER */
00182 
00183 #if !defined (SO_SNDBUF)
00184 #  define SO_SNDBUF 0x1001
00185 #endif /* SO_SNDBUF */
00186 
00187 #if !defined (SO_RCVBUF)
00188 #  define SO_RCVBUF 0x1002
00189 #endif /* SO_RCVBUF */
00190 
00191 #if !defined (SO_BROADCAST)
00192 #  define SO_BROADCAST 0x0020
00193 #endif /* SO_BROADCAST */
00194 
00195 #if !defined (SO_ERROR)
00196 #  define SO_ERROR 0x1007
00197 #endif /* SO_ERROR */
00198 
00199 #if !defined (SCM_RIGHTS)
00200 #  define SCM_RIGHTS 0x01
00201 #endif /* SCM_RIGHTS */
00202 
00203 #if defined (ACE_HAS_IPV6)
00204 #  if defined (ACE_USES_IPV4_IPV6_MIGRATION)
00205 #    define ACE_ADDRESS_FAMILY_INET  AF_UNSPEC
00206 #    define ACE_PROTOCOL_FAMILY_INET PF_UNSPEC
00207 #  else
00208 #    define ACE_ADDRESS_FAMILY_INET AF_INET6
00209 #    define ACE_PROTOCOL_FAMILY_INET PF_INET6
00210 #  endif /* ACE_USES_IPV4_IPV6_MIGRATION */
00211 #else /* !ACE_HAS_IPV6 */
00212 #  define ACE_ADDRESS_FAMILY_INET AF_INET
00213 #  define ACE_PROTOCOL_FAMILY_INET PF_INET
00214 #endif /* ACE_HAS_IPV6 */
00215 
00216 #if defined (ACE_HAS_SOCKLEN_T)
00217 #  if defined (__hpux)
00218   /*
00219   ** HP-UX supplies the socklen_t type unless some feature set less than
00220   ** _XOPEN_SOURCE_EXTENDED is specifically requested. However, it only
00221   ** actually uses the socklen_t type in supplied socket functions if
00222   ** _XOPEN_SOURCE_EXTENDED is specifically requested. So, for example,
00223   ** the compile options ACE usually uses (includes -mt) cause _HPUX_SOURCE
00224   ** to be set, which sets _INCLUDE_XOPEN_SOURCE_EXTENDED (causing socklen_t
00225   ** to be defined) but _not_ _XOPEN_SOURCE_EXTENDED (causing socket functions
00226   ** to use int, not socklen_t). React to this situation here...
00227   */
00228 #    if defined (_XOPEN_SOURCE_EXTENDED)
00229 typedef socklen_t ACE_SOCKET_LEN;
00230 #    else
00231 typedef int ACE_SOCKET_LEN;
00232 #    endif /* _XOPEN_SOURCE_EXTENDED */
00233 #  else
00234 typedef socklen_t ACE_SOCKET_LEN;
00235 #  endif /* __hpux */
00236 #elif defined (ACE_HAS_SIZET_SOCKET_LEN)
00237 typedef size_t ACE_SOCKET_LEN;
00238 #else
00239 typedef int ACE_SOCKET_LEN;
00240 #endif /* ACE_HAS_SIZET_SOCKET_LEN */
00241 
00242 #if defined (ACE_HAS_NETLINK)
00243 #  include /**/ <asm/types.h>
00244 #  include /**/ <linux/netlink.h>
00245 #  define ACE_PROTOCOL_FAMILY_NETLINK AF_NETLINK
00246 #endif
00247 
00248 #if defined (ACE_HAS_LKSCTP)
00249 extern "C"
00250 {
00251 #include /**/ <netinet/in.h>
00252 #include /**/ <netinet/sctp.h>
00253 }
00254 #endif /* ACE_HAS_LKSCTP */
00255 
00256 # if defined (ACE_LACKS_TIMEDWAIT_PROTOTYPES)
00257 
00258   ssize_t recv_timedwait (ACE_HANDLE handle,
00259                           char *buf,
00260                           int len,
00261                           int flags,
00262                           struct timespec *timeout);
00263 
00264   ssize_t recvmsg_timedwait (ACE_HANDLE handle,
00265                              struct msghdr *msg,
00266                              int flags,
00267                              struct timespec *timeout);
00268 
00269   ssize_t recvfrom_timedwait (ACE_HANDLE handle,
00270                               char *buf,
00271                               int len,
00272                               int flags,
00273                               struct sockaddr *addr,
00274                               int *addrlen,
00275                               struct timespec *timeout);
00276 
00277   ssize_t send_timedwait (ACE_HANDLE handle,
00278                           const char *buf,
00279                           int len,
00280                           int flags,
00281                           struct timespec *timeout);
00282 
00283   ssize_t sendmsg_timedwait (ACE_HANDLE handle,
00284                              const struct msghdr *msg,
00285                              int flags,
00286                              struct timespec *timeout);
00287 
00288   ssize_t sendto_timedwait (ACE_HANDLE handle,
00289                             const char *buf,
00290                             int len,
00291                             int flags,
00292                             const struct sockaddr *addr,
00293                             int addrlen,
00294                             struct timespec *timeout);
00295 
00296 # endif /* ACE_LACKS_TIMEDWAIT_PROTOTYPES */
00297 
00298 #ifdef __cplusplus
00299 }
00300 #endif /* __cplusplus */
00301 
00302 #include /**/ "ace/post.h"
00303 #endif /* ACE_OS_INCLUDE_SYS_OS_SOCKET_H */

Generated on Sun Jan 27 12:05:34 2008 for ACE by doxygen 1.3.6