SOCK_IO.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //==========================================================================
00004 /**
00005  *  @file    SOCK_IO.h
00006  *
00007  *  SOCK_IO.h,v 4.38 2006/02/25 23:01:14 shuston Exp
00008  *
00009  *  @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
00010  */
00011 //==========================================================================
00012 
00013 #ifndef ACE_SOCK_IO_H
00014 #define ACE_SOCK_IO_H
00015 
00016 #include /**/ "ace/pre.h"
00017 
00018 #include "ace/SOCK.h"
00019 
00020 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00021 # pragma once
00022 #endif /* ACE_LACKS_PRAGMA_ONCE */
00023 
00024 #include "ace/ACE.h"
00025 
00026 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00027 
00028 /**
00029  * @class ACE_SOCK_IO
00030  *
00031  * @brief Defines the methods for the ACE socket wrapper I/O routines
00032  * (e.g., send/recv).
00033  *
00034  *
00035  * If <timeout> == 0, then the call behaves as a normal
00036  * send/recv call, i.e., for blocking sockets, the call will
00037  * block until action is possible; for non-blocking sockets,
00038  * EWOULDBLOCK will be returned if no action is immediately
00039  * possible.
00040  * If <timeout> != 0, the call will wait until the relative time
00041  * specified in *<timeout> elapses.
00042  * Errors are reported by -1 and 0 return values.  If the
00043  * operation times out, -1 is returned with <errno == ETIME>.
00044  * If it succeeds the number of bytes transferred is returned.
00045  * Methods with the extra <flags> argument will always result in
00046  * <send> getting called. Methods without the extra <flags>
00047  * argument will result in <send> getting called on Win32
00048  * platforms, and <write> getting called on non-Win32 platforms.
00049  */
00050 class ACE_Export ACE_SOCK_IO : public ACE_SOCK
00051 {
00052 public:
00053   // = Initialization and termination methods.
00054 
00055   /// Constructor.
00056   ACE_SOCK_IO (void);
00057 
00058   /// Destructor.
00059   ~ACE_SOCK_IO (void);
00060 
00061   /// Recv an <n> byte buffer from the connected socket.
00062   ssize_t recv (void *buf,
00063                 size_t n,
00064                 int flags,
00065                 const ACE_Time_Value *timeout = 0) const;
00066 
00067   /// Recv an <n> byte buffer from the connected socket.
00068   ssize_t recv (void *buf,
00069                 size_t n,
00070                 const ACE_Time_Value *timeout = 0) const;
00071 
00072   /// Recv an <iovec> of size <n> from the connected socket.
00073   /**
00074    * @note The value of @a n will be silently reduced to the maximum
00075    * value an @c int can hold if needed. This is due to the underlying
00076    * system calls on many OSes limiting the number of @c iovec structures
00077    * that can be passed in one call.
00078    */
00079   ssize_t recvv (iovec iov[],
00080                  size_t n,
00081                  const ACE_Time_Value *timeout = 0) const;
00082 
00083   /// @deprecated Same as above.  Deprecated.
00084   ssize_t recv (iovec iov[],
00085                 size_t n,
00086                 const ACE_Time_Value *timeout = 0) const;
00087 
00088   /**
00089    * Allows a client to read from a socket without having to provide a
00090    * buffer to read.  This method determines how much data is in the
00091    * socket, allocates a buffer of this size, reads in the data, and
00092    * returns the number of bytes read.  The caller is responsible for
00093    * deleting the member in the <iov_base> field of <io_vec> using
00094    * delete [] io_vec->iov_base.
00095    */
00096   ssize_t recvv (iovec *io_vec,
00097                  const ACE_Time_Value *timeout = 0) const;
00098 
00099   /// Same as above.  Deprecated.
00100   ssize_t recv (iovec *io_vec,
00101                 const ACE_Time_Value *timeout = 0) const;
00102 
00103   /// Recv <n> varargs messages to the connected socket.
00104   ssize_t recv (size_t n,
00105                 ...) const;
00106 
00107   /// Recv <n> bytes via Win32 <ReadFile> using overlapped I/O.
00108   ssize_t recv (void *buf,
00109                 size_t n,
00110                 ACE_OVERLAPPED *overlapped) const;
00111 
00112   /// Send an <n> byte buffer to the connected socket.
00113   ssize_t send (const void *buf,
00114                 size_t n,
00115                 int flags,
00116                 const ACE_Time_Value *timeout = 0) const;
00117 
00118   /// Send an <n> byte buffer to the connected socket.
00119   ssize_t send (const void *buf,
00120                 size_t n,
00121                 const ACE_Time_Value *timeout = 0) const;
00122 
00123   /// Send an <iovec> of size <n> to the connected socket.
00124   /**
00125    * @note The value of @a n will be silently reduced to the maximum
00126    * value an @c int can hold if needed. This is due to the underlying
00127    * system calls on many OSes limiting the number of @c iovec structures
00128    * that can be passed in one call.
00129    */
00130   ssize_t sendv (const iovec iov[],
00131                  size_t n,
00132                  const ACE_Time_Value *timeout = 0) const;
00133 
00134   /// Same as above.  Deprecated.
00135   ssize_t send (const iovec iov[],
00136                 size_t n,
00137                 const ACE_Time_Value *timeout = 0) const;
00138 
00139   /// Send <n> varargs messages to the connected socket.
00140   ssize_t send (size_t n,
00141                 ...) const;
00142 
00143   /// Send <n> bytes via Win32 <WriteFile> using overlapped I/O.
00144   ssize_t send (const void *buf,
00145                 size_t n,
00146                 ACE_OVERLAPPED *overlapped) const;
00147 
00148   /// Dump the state of an object.
00149   void dump (void) const;
00150 
00151   /// Declare the dynamic allocation hooks.
00152   ACE_ALLOC_HOOK_DECLARE;
00153 };
00154 
00155 ACE_END_VERSIONED_NAMESPACE_DECL
00156 
00157 #if defined (__ACE_INLINE__)
00158 #include "ace/SOCK_IO.inl"
00159 #endif /* __ACE_INLINE__ */
00160 
00161 #include /**/ "ace/post.h"
00162 
00163 #endif /* ACE_SOCK_IO_H */

Generated on Thu Nov 9 09:42:04 2006 for ACE by doxygen 1.3.6