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  *  os_socket.h,v 1.15 2006/06/07 13:35:33 jwillemsen Exp
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 #  if defined (ACE_HAS_AIX_BROKEN_SOCKET_HEADER)
00031 #    undef __cplusplus
00032 #  endif /* ACE_HAS_AIX_BROKEN_SOCKET_HEADER */
00033 #  include /**/ <sys/socket.h>
00034 #  if defined (ACE_HAS_AIX_BROKEN_SOCKET_HEADER)
00035 #    define __cplusplus
00036 #  endif /* ACE_HAS_AIX_BROKEN_SOCKET_HEADER */
00037 #endif /* !ACE_LACKS_SYS_SOCKET_H */
00038 
00039 #if defined (ACE_VXWORKS) && (ACE_VXWORKS < 0x620)
00040 #  include /**/ <sockLib.h>
00041 #endif /* ACE_VXWORKS */
00042 
00043 // Place all additions (especially function declarations) within extern "C" {}
00044 #ifdef __cplusplus
00045 extern "C"
00046 {
00047 #endif /* __cplusplus */
00048 
00049 #if !defined (ACE_HAS_MSG) && !defined (SCO)
00050    struct msghdr {};
00051 #endif /* ACE_HAS_MSG */
00052 
00053 #if defined (ACE_HAS_MSG) && defined (ACE_LACKS_MSG_ACCRIGHTS)
00054 #  if !defined (msg_accrights)
00055 #    undef msg_control
00056 #    define msg_accrights msg_control
00057 #  endif /* ! msg_accrights */
00058 
00059 #  if !defined (msg_accrightslen)
00060 #    undef msg_controllen
00061 #    define msg_accrightslen msg_controllen
00062 #  endif /* ! msg_accrightslen */
00063 #endif /* ACE_HAS_MSG && ACE_LACKS_MSG_ACCRIGHTS */
00064 
00065 #if defined (ACE_WIN32)
00066    struct msghdr
00067    {
00068      /// Optional address
00069      sockaddr * msg_name;
00070 
00071      /// Size of address
00072      int msg_namelen;
00073 
00074      /// Scatter/gather array
00075      iovec *msg_iov;
00076 
00077      /// # elements in msg_iov
00078      int msg_iovlen;
00079 
00080      /// Access rights sent/received
00081      caddr_t msg_accrights;
00082 
00083      int msg_accrightslen;
00084    };
00085 #endif /* ACE_WIN32 */
00086 
00087 #if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG)
00088    // Control message size to pass a file descriptor.
00089 #  define ACE_BSD_CONTROL_MSG_LEN sizeof (struct cmsghdr) + sizeof (ACE_HANDLE)
00090 #  if defined (ACE_LACKS_CMSG_DATA_MACRO)
00091 #    if defined (ACE_LACKS_CMSG_DATA_MEMBER)
00092 #      define CMSG_DATA(cmsg) ((unsigned char *) ((struct cmsghdr *) (cmsg) + 1))
00093 #    else
00094 #      define CMSG_DATA(cmsg) ((cmsg)->cmsg_data)
00095 #    endif /* ACE_LACKS_CMSG_DATA_MEMBER */
00096 #  endif /* ACE_LACKS_CMSG_DATA_MACRO */
00097 #endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */
00098 
00099 // Increase the range of "address families".  Please note that this
00100 // must appear _after_ the include of sys/socket.h, for the AF_FILE
00101 // definition on Linux/glibc2.
00102 #if !defined (AF_ANY)
00103 #  define AF_ANY (-1)
00104 #endif /* AF_ANY */
00105 
00106 #define AF_SPIPE (AF_MAX + 1)
00107 #if !defined (AF_FILE)
00108 #  define AF_FILE (AF_MAX + 2)
00109 #endif /* ! AF_FILE */
00110 #define AF_DEV (AF_MAX + 3)
00111 #define AF_UPIPE (AF_SPIPE)
00112 
00113 #if defined (ACE_HAS_IPV6)
00114 #  if defined (ACE_USES_IPV4_IPV6_MIGRATION)
00115 #    define ACE_ADDRESS_FAMILY_INET  AF_UNSPEC
00116 #    define ACE_PROTOCOL_FAMILY_INET PF_UNSPEC
00117 #  else
00118 #    define ACE_ADDRESS_FAMILY_INET AF_INET6
00119 #    define ACE_PROTOCOL_FAMILY_INET PF_INET6
00120 #  endif /* ACE_USES_IPV4_IPV6_MIGRATION */
00121 #else /* !ACE_HAS_IPV6 */
00122 #  define ACE_ADDRESS_FAMILY_INET AF_INET
00123 #  define ACE_PROTOCOL_FAMILY_INET PF_INET
00124 #endif /* ACE_HAS_IPV6 */
00125 
00126 #if defined (ACE_HAS_SOCKLEN_T)
00127 #  if defined (__hpux)
00128   /*
00129   ** HP-UX supplies the socklen_t type unless some feature set less than
00130   ** _XOPEN_SOURCE_EXTENDED is specifically requested. However, it only
00131   ** actually uses the socklen_t type in supplied socket functions if
00132   ** _XOPEN_SOURCE_EXTENDED is specifically requested. So, for example,
00133   ** the compile options ACE usually uses (includes -mt) cause _HPUX_SOURCE
00134   ** to be set, which sets _INCLUDE_XOPEN_SOURCE_EXTENDED (causing socklen_t
00135   ** to be defined) but _not_ _XOPEN_SOURCE_EXTENDED (causing socket functions
00136   ** to use int, not socklen_t). React to this situation here...
00137   */
00138 #    if defined (_XOPEN_SOURCE_EXTENDED)
00139 typedef socklen_t ACE_SOCKET_LEN;
00140 #    else
00141 typedef int ACE_SOCKET_LEN;
00142 #    endif /* _XOPEN_SOURCE_EXTENDED */
00143 #  else
00144 typedef socklen_t ACE_SOCKET_LEN;
00145 #  endif /* __hpux */
00146 #elif defined (ACE_HAS_SIZET_SOCKET_LEN)
00147 typedef size_t ACE_SOCKET_LEN;
00148 #else
00149 typedef int ACE_SOCKET_LEN;
00150 #endif /* ACE_HAS_SIZET_SOCKET_LEN */
00151 
00152 #if defined (ACE_HAS_NETLINK)
00153 #  include /**/ <asm/types.h>
00154 #  include /**/ <linux/netlink.h>
00155 #  define ACE_PROTOCOL_FAMILY_NETLINK AF_NETLINK
00156 #endif
00157 
00158 #if defined (ACE_HAS_LKSCTP)
00159 extern "C"
00160 {
00161 #include /**/ <netinet/in.h>
00162 #include /**/ <netinet/sctp.h>
00163 }
00164 #endif /* ACE_HAS_LKSCTP */
00165 
00166 # if defined (ACE_LACKS_TIMEDWAIT_PROTOTYPES)
00167 
00168   ssize_t recv_timedwait (ACE_HANDLE handle,
00169                           char *buf,
00170                           int len,
00171                           int flags,
00172                           struct timespec *timeout);
00173 
00174   ssize_t recvmsg_timedwait (ACE_HANDLE handle,
00175                              struct msghdr *msg,
00176                              int flags,
00177                              struct timespec *timeout);
00178 
00179   ssize_t recvfrom_timedwait (ACE_HANDLE handle,
00180                               char *buf,
00181                               int len,
00182                               int flags,
00183                               struct sockaddr *addr,
00184                               int *addrlen,
00185                               struct timespec *timeout);
00186 
00187   ssize_t send_timedwait (ACE_HANDLE handle,
00188                           const char *buf,
00189                           int len,
00190                           int flags,
00191                           struct timespec *timeout);
00192 
00193   ssize_t sendmsg_timedwait (ACE_HANDLE handle,
00194                              const struct msghdr *msg,
00195                              int flags,
00196                              struct timespec *timeout);
00197 
00198   ssize_t sendto_timedwait (ACE_HANDLE handle,
00199                             const char *buf,
00200                             int len,
00201                             int flags,
00202                             const struct sockaddr *addr,
00203                             int addrlen,
00204                             struct timespec *timeout);
00205 
00206 # endif /* ACE_LACKS_TIMEDWAIT_PROTOTYPES */
00207 
00208 #ifdef __cplusplus
00209 }
00210 #endif /* __cplusplus */
00211 
00212 #include /**/ "ace/post.h"
00213 #endif /* ACE_OS_INCLUDE_SYS_OS_SOCKET_H */

Generated on Thu Nov 9 09:41:58 2006 for ACE by doxygen 1.3.6