Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

SPIPE_Stream.h

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

Generated on Mon Jun 16 11:21:23 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002