SPIPE_Stream.h

Go to the documentation of this file.
00001 /* -*- C++ -*- */
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    SPIPE_Stream.h
00006  *
00007  *  SPIPE_Stream.h,v 4.22 2005/11/24 09:48:54 ossama Exp
00008  *
00009  *  @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
00010  */
00011 //=============================================================================
00012 
00013 #ifndef ACE_SPIPE_STREAM_H
00014 #define ACE_SPIPE_STREAM_H
00015 #include /**/ "ace/pre.h"
00016 
00017 #include "ace/SPIPE.h"
00018 
00019 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00020 # pragma once
00021 #endif /* ACE_LACKS_PRAGMA_ONCE */
00022 
00023 #include "ace/SPIPE_Addr.h"
00024 #include "ace/ACE.h"
00025 #include "ace/OS_NS_stropts.h"
00026 
00027 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00028 
00029 /**
00030  * @class ACE_SPIPE_Stream
00031  *
00032  * @brief Defines the methods in the <ACE_SPIPE_Stream> abstraction.
00033  *
00034  * <buf> is the buffer to write from or receive into.
00035  * <len> is the number of bytes to transfer.
00036  *
00037  * The "_n()" I/O methods keep looping until all the data has been
00038  * transferred.  These methods also work for sockets in non-blocking
00039  * mode i.e., they keep looping on EWOULDBLOCK.
00040  *
00041  * The return values for the "*_n()" methods match the return values
00042  * from the non "_n()" methods and are specified as follows:
00043  * - The number of bytes transferred is returned.
00044  * - On error, -1 is returned, errno is set to appropriate error.
00045  * - On EOF, 0 is returned, errno is irrelevant.
00046  *
00047  * Methods with <iovec> parameter are I/O vector variants of the I/O
00048  * operations.
00049  *
00050  * The <send> and <revc> operations use "message" semantics rather
00051  * than "bytestream" semantics.
00052  */
00053 class ACE_Export ACE_SPIPE_Stream : public ACE_SPIPE
00054 {
00055 public:
00056   friend class ACE_SPIPE_Acceptor;
00057   friend class ACE_SPIPE_Connector;
00058 
00059   // = Initialization method.
00060   /// Default constructor.
00061   ACE_SPIPE_Stream (void);
00062 
00063   /// Obtain the address of whom we are connected with.
00064   int get_remote_addr (ACE_SPIPE_Addr &remote_sap) const;
00065 
00066   /// Send an open FD to another process.
00067   int send_handle (ACE_HANDLE handle) const;
00068 
00069   /// Recv an open FD from another process.
00070   int recv_handle (ACE_HANDLE &handle) const;
00071 
00072   /// Recv an open FD from another process.
00073   int recv_handle (strrecvfd &recvfd) const;
00074 
00075   /// Send <len> bytes, keep trying until <len> are sent.
00076   ssize_t send_n (const void *buf, size_t len) const;
00077 
00078   /// Recv <len> bytes, keep trying until <len> are received.
00079   ssize_t recv_n (void *buf, size_t len) const;
00080 
00081   /// Send bytes via STREAM pipes using "band" mode.
00082   ssize_t send (const void *buf, size_t len) const;
00083 
00084   /// Recv bytes via STREAM pipes using "band" mode.
00085   ssize_t recv (void *buf, size_t len) const;
00086 
00087   /// Send <cntl> and <data> via STREAM pipes.
00088   ssize_t send (const ACE_Str_Buf *cntl,
00089                 const ACE_Str_Buf *data,
00090                 int flags = 0) const;
00091 
00092   /// Recv <cntl> and <data> via STREAM pipes.
00093   ssize_t recv (ACE_Str_Buf *cntl,
00094                 ACE_Str_Buf *data,
00095                 int *flags) const;
00096 
00097   /// Send bytes via STREAM pipes using "band" mode.
00098   ssize_t send (const ACE_Str_Buf *cntl,
00099                 const ACE_Str_Buf *data,
00100                 int band,
00101                 int flags) const;
00102 
00103   /// Recv bytes via STREAM pipes using "band" mode.
00104   ssize_t recv (ACE_Str_Buf *cntl,
00105                 ACE_Str_Buf *data,
00106                 int *band,
00107                 int *flags) const;
00108 
00109   /// Send iovecs via the OS "gather-write" operation.
00110   ssize_t send (const iovec iov[], int len) const;
00111 
00112   /// Recv iovecs via the OS "scatter-read" operation.
00113   ssize_t recv (iovec iov[], int len) const;
00114 
00115   /**
00116    * Send N char *ptrs and int lengths.  Note that the char *'s
00117    * precede the ints (basically, an varargs version of writev).  The
00118    * count N is the *total* number of trailing arguments, *not* a
00119    * couple of the number of tuple pairs!
00120    */
00121   ssize_t send (size_t len, ...) const;
00122 
00123   /**
00124    * This is an interface to ::readv, that doesn't use the struct
00125    * iovec explicitly.  The ... can be passed as an arbitrary number
00126    * of (char *ptr, int len) tuples.  However, the count N is the
00127    * *total* number of trailing arguments, *not* a couple of the
00128    * number of tuple pairs!
00129    */
00130   ssize_t recv (size_t len, ...) const;
00131 
00132   /// Send <len> bytes via Win32 <WriteFile> using overlapped I/O.
00133   ssize_t send (const void *buf, size_t len, ACE_OVERLAPPED *overlapped) const;
00134 
00135   /// Recv <len> bytes via Win32 <ReadFile> using overlapped I/O.
00136   ssize_t recv (void *buf, size_t len, ACE_OVERLAPPED *overlapped) const;
00137 
00138   /// Send an <iovec> of size <len> to the stream.
00139   ssize_t sendv (const iovec iov[],
00140                  int len) const;
00141 
00142   /// Send an <iovec> of size <len> to the stream.  Will block until all
00143   /// bytes are sent or an error occurs.
00144   ssize_t sendv_n (const iovec iov[],
00145                    int len) const;
00146 
00147   /// Receive an <iovec> of size <len> to the stream.
00148   ssize_t recvv_n (iovec iov[],
00149                    int len) const;
00150 
00151   // = Meta-type info
00152   typedef ACE_SPIPE_Addr PEER_ADDR;
00153 
00154   /// Dump the state of an object.
00155   void dump (void) const;
00156 
00157   /// Declare the dynamic allocation hooks.
00158   ACE_ALLOC_HOOK_DECLARE;
00159 
00160 private:
00161   ACE_SPIPE_Addr remote_addr_;
00162 };
00163 
00164 ACE_END_VERSIONED_NAMESPACE_DECL
00165 
00166 #if defined (__ACE_INLINE__)
00167 #include "ace/SPIPE_Stream.inl"
00168 #endif /* __ACE_INLINE__ */
00169 
00170 #include /**/ "ace/post.h"
00171 #endif /* ACE_SPIPE_STREAM_H */

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