SOCK_IO.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //==========================================================================
00004 /**
00005  *  @file    SOCK_IO.h
00006  *
00007  *  $Id: SOCK_IO.h 81014 2008-03-19 11:41:31Z johnnyw $
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  * If @a timeout == 0, then the call behaves as a normal
00035  * send/recv call, i.e., for blocking sockets, the call will
00036  * block until action is possible; for non-blocking sockets,
00037  * -1 will be returned with errno == EWOULDBLOCK if no action is
00038  * immediately possible.
00039  * If @a timeout != 0, the call will wait until the relative time
00040  * specified in *@a timeout elapses.
00041  * Errors are reported by -1 and 0 return values.  If the
00042  * operation times out, -1 is returned with @c errno == ETIME.
00043  * If it succeeds the number of bytes transferred is returned.
00044  * Methods with the extra @a flags argument will always result in
00045  * @c send getting called. Methods without the extra @a flags
00046  * argument will result in @c send getting called on Win32
00047  * platforms, and @c write getting called on non-Win32 platforms.
00048  */
00049 class ACE_Export ACE_SOCK_IO : public ACE_SOCK
00050 {
00051 public:
00052   // = Initialization and termination methods.
00053 
00054   /// Constructor.
00055   ACE_SOCK_IO (void);
00056 
00057   /// Destructor.
00058   ~ACE_SOCK_IO (void);
00059 
00060   /// Recv an @a n byte buffer from the connected socket.
00061   ssize_t recv (void *buf,
00062                 size_t n,
00063                 int flags,
00064                 const ACE_Time_Value *timeout = 0) const;
00065 
00066   /// Recv an @a n byte buffer from the connected socket.
00067   ssize_t recv (void *buf,
00068                 size_t n,
00069                 const ACE_Time_Value *timeout = 0) const;
00070 
00071   /// Recv an <iovec> of size @a n from the connected socket.
00072   ssize_t recvv (iovec iov[],
00073                  int n,
00074                  const ACE_Time_Value *timeout = 0) const;
00075 
00076   /**
00077    * Allows a client to read from a socket without having to provide a
00078    * buffer to read.  This method determines how much data is in the
00079    * socket, allocates a buffer of this size, reads in the data, and
00080    * returns the number of bytes read.  The caller is responsible for
00081    * deleting the member in the <iov_base> field of @a io_vec using
00082    * delete [] io_vec->iov_base.
00083    */
00084   ssize_t recvv (iovec *io_vec,
00085                  const ACE_Time_Value *timeout = 0) const;
00086 
00087   /// Recv @a n varargs messages to the connected socket.
00088   ssize_t recv (size_t n,
00089                 ...) const;
00090 
00091   /// Recv @a n bytes via Win32 @c ReadFile using overlapped I/O.
00092   ssize_t recv (void *buf,
00093                 size_t n,
00094                 ACE_OVERLAPPED *overlapped) const;
00095 
00096   /// Send an @a n byte buffer to the connected socket.
00097   ssize_t send (const void *buf,
00098                 size_t n,
00099                 int flags,
00100                 const ACE_Time_Value *timeout = 0) const;
00101 
00102   /// Send an @a n byte buffer to the connected socket.
00103   ssize_t send (const void *buf,
00104                 size_t n,
00105                 const ACE_Time_Value *timeout = 0) const;
00106 
00107   /// Send an @c iovec of size @a n to the connected socket.
00108   ssize_t sendv (const iovec iov[],
00109                  int n,
00110                  const ACE_Time_Value *timeout = 0) const;
00111 
00112   /// Send @a n varargs messages to the connected socket.
00113   ssize_t send (size_t n,
00114                 ...) const;
00115 
00116   /// Send @a n bytes via Win32 <WriteFile> using overlapped I/O.
00117   ssize_t send (const void *buf,
00118                 size_t n,
00119                 ACE_OVERLAPPED *overlapped) const;
00120 
00121   /// Dump the state of an object.
00122   void dump (void) const;
00123 
00124   /// Declare the dynamic allocation hooks.
00125   ACE_ALLOC_HOOK_DECLARE;
00126 };
00127 
00128 ACE_END_VERSIONED_NAMESPACE_DECL
00129 
00130 #if defined (__ACE_INLINE__)
00131 #include "ace/SOCK_IO.inl"
00132 #endif /* __ACE_INLINE__ */
00133 
00134 #include /**/ "ace/post.h"
00135 
00136 #endif /* ACE_SOCK_IO_H */

Generated on Tue Feb 2 17:18:42 2010 for ACE by  doxygen 1.4.7