OS_NS_sys_socket.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file   OS_NS_sys_socket.h
00006  *
00007  *  OS_NS_sys_socket.h,v 1.11 2006/02/28 00:23:12 shuston Exp
00008  *
00009  *  @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
00010  *  @author Jesper S. M|ller<stophph@diku.dk>
00011  *  @author and a cast of thousands...
00012  *
00013  *  Originally in OS.h.
00014  */
00015 //=============================================================================
00016 
00017 #ifndef ACE_OS_NS_SYS_SOCKET_H
00018 # define ACE_OS_NS_SYS_SOCKET_H
00019 
00020 # include /**/ "ace/pre.h"
00021 
00022 # include "ace/config-all.h"
00023 
00024 # if !defined (ACE_LACKS_PRAGMA_ONCE)
00025 #  pragma once
00026 # endif /* ACE_LACKS_PRAGMA_ONCE */
00027 
00028 #include "ace/os_include/sys/os_socket.h"
00029 #include "ace/os_include/net/os_if.h"
00030 #include "ace/OS_NS_stropts.h"
00031 #include "ace/ACE_export.h"
00032 
00033 #if defined (ACE_EXPORT_MACRO)
00034 #  undef ACE_EXPORT_MACRO
00035 #endif
00036 #define ACE_EXPORT_MACRO ACE_Export
00037 
00038 /// These are available values for the @a how argument to ACE_OS::shutdown().
00039 #if defined (SD_RECEIVE)
00040 #define ACE_SHUTDOWN_READ SD_RECEIVE
00041 #elif defined (SHUT_RD)
00042 #define ACE_SHUTDOWN_READ SHUT_RD
00043 #else
00044 #define ACE_SHUTDOWN_READ 0
00045 #endif /* SD_RECEIVE */
00046 
00047 #if defined (SD_SEND)
00048 #define ACE_SHUTDOWN_WRITE SD_SEND
00049 #elif defined (SHUT_WR)
00050 #define ACE_SHUTDOWN_WRITE SHUT_WR
00051 #else
00052 #define ACE_SHUTDOWN_WRITE 1
00053 #endif /* SD_SEND */
00054 
00055 #if defined (SD_BOTH)
00056 #define ACE_SHUTDOWN_BOTH SD_BOTH
00057 #elif defined (SHUT_RDWR)
00058 #define ACE_SHUTDOWN_BOTH SHUT_RDWR
00059 #else
00060 #define ACE_SHUTDOWN_BOTH 2
00061 #endif /* SD_BOTH */
00062 
00063 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00064 
00065 class ACE_Accept_QoS_Params;
00066 class ACE_QoS_Params;
00067 
00068 namespace ACE_OS
00069 {
00070 
00071 # if defined (ACE_WIN32)
00072   /// Keeps track of whether we've already initialized WinSock...
00073   extern ACE_Export int socket_initialized_;
00074 # endif /* ACE_WIN32 */
00075 
00076   //@{ @name A set of wrappers for sockets.
00077   /// BSD-style <accept> (no QoS).
00078   ACE_NAMESPACE_INLINE_FUNCTION
00079   ACE_HANDLE accept (ACE_HANDLE handle,
00080                      struct sockaddr *addr,
00081                      int *addrlen);
00082 
00083 #if !(defined (ACE_HAS_WINCE) && (UNDER_CE < 500))
00084   /**
00085    * QoS-enabled <accept>, which passes <qos_params> to <accept>.  If
00086    * the OS platform doesn't support QoS-enabled <accept> then the
00087    * <qos_params> are ignored and the BSD-style <accept> is called.
00088    */
00089   extern ACE_Export
00090   ACE_HANDLE accept (ACE_HANDLE handle,
00091                      struct sockaddr *addr,
00092                      int *addrlen,
00093                      const ACE_Accept_QoS_Params &qos_params);
00094 #endif  /* !(defined (ACE_HAS_WINCE) && (UNDER_CE < 500)) */
00095 
00096   ACE_NAMESPACE_INLINE_FUNCTION
00097   int bind (ACE_HANDLE s,
00098             struct sockaddr *name,
00099             int namelen);
00100 
00101   // takes care of windows specific requirement to call closesocket
00102   ACE_NAMESPACE_INLINE_FUNCTION
00103   int closesocket (ACE_HANDLE s);
00104 
00105   /// BSD-style <connect> (no QoS).
00106   ACE_NAMESPACE_INLINE_FUNCTION
00107   int connect (ACE_HANDLE handle,
00108                struct sockaddr *addr,
00109                int addrlen);
00110 
00111 #if !(defined (ACE_HAS_WINCE) && (UNDER_CE < 500))
00112   /**
00113    * QoS-enabled <connect>, which passes <qos_params> to <connect>.
00114    * If the OS platform doesn't support QoS-enabled <connect> then the
00115    * <qos_params> are ignored and the BSD-style <connect> is called.
00116    */
00117   extern ACE_Export
00118   int connect (ACE_HANDLE handle,
00119                const sockaddr *addr,
00120                int addrlen,
00121                const ACE_QoS_Params &qos_params);
00122 #endif  /* !(defined (ACE_HAS_WINCE) && (UNDER_CE < 500)) */
00123 
00124   /// Retrieve information about available transport protocols
00125   /// installed on the local machine. Windows specific...
00126   ACE_NAMESPACE_INLINE_FUNCTION
00127   int enum_protocols (int *protocols,
00128                       ACE_Protocol_Info *protocol_buffer,
00129                       u_long *buffer_length);
00130 
00131   ACE_NAMESPACE_INLINE_FUNCTION
00132   int getpeername (ACE_HANDLE handle,
00133                    struct sockaddr *addr,
00134                    int *addrlen);
00135 
00136   ACE_NAMESPACE_INLINE_FUNCTION
00137   int getsockname (ACE_HANDLE handle,
00138                    struct sockaddr *addr,
00139                    int *addrlen);
00140   ACE_NAMESPACE_INLINE_FUNCTION
00141   int getsockopt (ACE_HANDLE handle,
00142                   int level,
00143                   int optname,
00144                   char *optval,
00145                   int *optlen);
00146 
00147 #if !(defined (ACE_HAS_WINCE) && (UNDER_CE < 500))
00148   /// Joins a leaf node into a QoS-enabled multi-point session.
00149   extern ACE_Export
00150   ACE_HANDLE join_leaf (ACE_HANDLE socket,
00151                         const sockaddr *name,
00152                         int namelen,
00153                         const ACE_QoS_Params &qos_params);
00154 #endif  /* !(defined (ACE_HAS_WINCE) && (UNDER_CE < 500)) */
00155 
00156   ACE_NAMESPACE_INLINE_FUNCTION
00157   int listen (ACE_HANDLE handle,
00158               int backlog);
00159 
00160   ACE_NAMESPACE_INLINE_FUNCTION
00161   ssize_t recv (ACE_HANDLE handle,
00162                 char *buf,
00163                 size_t len,
00164                 int flags = 0);
00165 
00166   ACE_NAMESPACE_INLINE_FUNCTION
00167   ssize_t recvfrom (ACE_HANDLE handle,
00168                     char *buf,
00169                     size_t len,
00170                     int flags,
00171                     struct sockaddr *addr,
00172                     int *addrlen);
00173 
00174   ACE_NAMESPACE_INLINE_FUNCTION
00175   ssize_t recvfrom (ACE_HANDLE handle,
00176                     iovec *buffers,
00177                     int buffer_count,
00178                     size_t &number_of_bytes_recvd,
00179                     int &flags,
00180                     struct sockaddr *addr,
00181                     int *addrlen,
00182                     ACE_OVERLAPPED *overlapped,
00183                     ACE_OVERLAPPED_COMPLETION_FUNC func);
00184 
00185   ACE_NAMESPACE_INLINE_FUNCTION
00186   ssize_t recvmsg (ACE_HANDLE handle,
00187                    struct msghdr *msg,
00188                    int flags);
00189 
00190   ACE_NAMESPACE_INLINE_FUNCTION
00191   ssize_t recvv (ACE_HANDLE handle,
00192                  iovec *iov,
00193                  int iovlen);
00194 
00195   ACE_NAMESPACE_INLINE_FUNCTION
00196   ssize_t send (ACE_HANDLE handle,
00197                 const char *buf,
00198                 size_t len,
00199                 int flags = 0);
00200 
00201   ACE_NAMESPACE_INLINE_FUNCTION
00202   ssize_t sendmsg (ACE_HANDLE handle,
00203                    const struct msghdr *msg,
00204                    int flags);
00205 
00206   ACE_NAMESPACE_INLINE_FUNCTION
00207   ssize_t sendto (ACE_HANDLE handle,
00208                   const char *buf,
00209                   size_t len,
00210                   int flags,
00211                   const struct sockaddr *addr,
00212                   int addrlen);
00213 
00214   ACE_NAMESPACE_INLINE_FUNCTION
00215   ssize_t sendto (ACE_HANDLE handle,
00216                   const iovec *buffers,
00217                   int buffer_count,
00218                   size_t &number_of_bytes_sent,
00219                   int flags,
00220                   const struct sockaddr *addr,
00221                   int addrlen,
00222                   ACE_OVERLAPPED *overlapped,
00223                   ACE_OVERLAPPED_COMPLETION_FUNC func);
00224 
00225   ACE_NAMESPACE_INLINE_FUNCTION
00226   ssize_t sendv (ACE_HANDLE handle,
00227                  const iovec *iov,
00228                  int iovcnt);
00229 
00230 
00231   /// Manipulate the options associated with a socket.
00232   ACE_NAMESPACE_INLINE_FUNCTION
00233   int setsockopt (ACE_HANDLE handle,
00234                   int level,
00235                   int optname,
00236                   const char *optval,
00237                   int optlen);
00238 
00239   ACE_NAMESPACE_INLINE_FUNCTION
00240   int shutdown (ACE_HANDLE handle,
00241                 int how);
00242 
00243 #if defined (__linux__) && defined (ACE_HAS_IPV6)
00244   ACE_NAMESPACE_INLINE_FUNCTION
00245   unsigned int if_nametoindex (const char *ifname);
00246 
00247   ACE_NAMESPACE_INLINE_FUNCTION
00248   char *if_indextoname (unsigned int ifindex, char *ifname);
00249 
00250   ACE_NAMESPACE_INLINE_FUNCTION
00251   struct if_nameindex *if_nameindex (void);
00252 
00253   ACE_NAMESPACE_INLINE_FUNCTION
00254   void if_freenameindex (struct if_nameindex *ptr);
00255 #endif /* __linux__ && ACE_HAS_IPV6 */
00256 
00257   /// Initialize WinSock before first use (e.g., when a DLL is first
00258   /// loaded or the first use of a socket() call.
00259   extern ACE_Export
00260   int socket_init (int version_high = 1,
00261                    int version_low = 1);
00262 
00263   /// Finalize WinSock after last use (e.g., when a DLL is unloaded).
00264   extern ACE_Export
00265   int socket_fini (void);
00266 
00267   /// Create a BSD-style socket (no QoS).
00268   ACE_NAMESPACE_INLINE_FUNCTION
00269   ACE_HANDLE socket (int protocol_family,
00270                      int type,
00271                      int proto);
00272 
00273   /// Create a QoS-enabled socket.  If the OS platform doesn't support
00274   /// QoS-enabled <socket> then the BSD-style <socket> is called.
00275   ACE_NAMESPACE_INLINE_FUNCTION
00276   ACE_HANDLE socket (int protocol_family,
00277                      int type,
00278                      int proto,
00279                      ACE_Protocol_Info *protocolinfo,
00280                      ACE_SOCK_GROUP g,
00281                      u_long flags);
00282 
00283   ACE_NAMESPACE_INLINE_FUNCTION
00284   int socketpair (int domain,
00285                   int type,
00286                   int protocol,
00287                   ACE_HANDLE sv[2]);
00288 
00289 } /* namespace ACE_OS */
00290 
00291 ACE_END_VERSIONED_NAMESPACE_DECL
00292 
00293 # if defined (ACE_HAS_INLINED_OSCALLS)
00294 #   if defined (ACE_INLINE)
00295 #     undef ACE_INLINE
00296 #   endif /* ACE_INLINE */
00297 #   define ACE_INLINE inline
00298 #   include "ace/OS_NS_sys_socket.inl"
00299 # endif /* ACE_HAS_INLINED_OSCALLS */
00300 
00301 # include /**/ "ace/post.h"
00302 #endif /* ACE_OS_NS_SYS_SOCKET_H */

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