00001 /* -*- C++ -*- */ 00002 00003 //============================================================================= 00004 /** 00005 * @file MEM_Stream.h 00006 * 00007 * $Id: MEM_Stream.h,v 1.1.1.3 2001/12/04 14:33:03 chad Exp $ 00008 * 00009 * @author Nanbor Wang <nanbor@cs.wustl.edu> 00010 */ 00011 //============================================================================= 00012 00013 00014 #ifndef ACE_MEM_STREAM_H 00015 #define ACE_MEM_STREAM_H 00016 #include "ace/pre.h" 00017 00018 #include "ace/MEM_IO.h" 00019 00020 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00021 # pragma once 00022 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00023 00024 #if (ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1) 00025 00026 #include "ace/INET_Addr.h" 00027 00028 class ACE_MEM_Acceptor; 00029 class ACE_MEM_Connector; 00030 00031 /** 00032 * @class ACE_MEM_Stream 00033 * 00034 * @brief Defines the methods in the <ACE_MEM_Stream> abstraction. 00035 * 00036 * This adds additional wrapper methods atop the <ACE_MEM_IO> 00037 * class. 00038 */ 00039 class ACE_Export ACE_MEM_Stream : public ACE_MEM_IO 00040 { 00041 public: 00042 00043 friend class ACE_MEM_Acceptor; 00044 friend class ACE_MEM_Connector; 00045 00046 // Initialization and termination methods. 00047 /// Constructor. 00048 ACE_MEM_Stream (void); 00049 00050 /// Constructor (sets the underlying <ACE_HANDLE> with <h>). 00051 ACE_MEM_Stream (ACE_HANDLE h); 00052 00053 /// Destructor. 00054 ~ACE_MEM_Stream (void); 00055 00056 //= The following two methods use write and read system calls. 00057 /// Send n bytes, keep trying until n are sent. 00058 /// Recv n bytes, keep trying until n are received. 00059 ssize_t send_n (const void *buf, int n); 00060 ssize_t recv_n (void *buf, int n); 00061 00062 // = The following two methods use the send and recv system calls. 00063 /// Send n bytes, keep trying until n are sent. 00064 /// Recv n bytes, keep trying until n are received. 00065 ssize_t send_n (const void *buf, int n, int flags); 00066 ssize_t recv_n (void *buf, int n, int flags); 00067 00068 #if 0 00069 /** 00070 * Try to send exactly <len> bytes into <buf> from <handle> (uses 00071 * the <send> call). If <send> blocks for longer than <timeout> the 00072 * number of bytes actually sent is returned with <errno == ETIME>. 00073 * If a timeout does not occur, <send_n> return <len> (i.e., the 00074 * number of bytes requested to be sent). 00075 */ 00076 ssize_t send_n (const void *buf, 00077 size_t len, 00078 int flags, 00079 const ACE_Time_Value *timeout); 00080 00081 /** 00082 * Try to recv exactly <len> bytes into <buf> from <handle> (uses 00083 * the <ACE::recv_n> call). The <ACE_Time_Value> indicates how long 00084 * to blocking trying to receive. If <timeout> == 0, the caller 00085 * will block until action is possible, else will wait until the 00086 * relative time specified in *<timeout> elapses). If <recv> blocks 00087 * for longer than <timeout> the number of bytes actually read is 00088 * returned with <errno == ETIME>. If a timeout does not occur, 00089 * <recv_n> return <len> (i.e., the number of bytes requested to be 00090 * read). 00091 */ 00092 ssize_t recv_n (void *buf, 00093 size_t len, 00094 int flags, 00095 const ACE_Time_Value *timeout); 00096 00097 /** 00098 * Send an <iovec> of size <n> to the connected socket (uses 00099 * <ACE::sendv_n>). Will block until all bytes are sent or an error 00100 * occurs. 00101 */ 00102 ssize_t sendv_n (const iovec iov[], 00103 size_t n) const; 00104 00105 /// Receive an <iovec> of size <n> to the connected socket. 00106 ssize_t recvv_n (iovec iov[], 00107 size_t n) const; 00108 #endif /* 0 */ 00109 00110 // = Selectively close endpoints. 00111 00112 /// Close down the reader. 00113 int close_reader (void); 00114 00115 /// Close down the writer. 00116 int close_writer (void); 00117 00118 /** 00119 * Close down the socket (we need this to make things work correctly 00120 * on Win32, which requires use to do a <close_writer> before doing 00121 * the close to avoid losing data). 00122 */ 00123 int close (void); 00124 00125 // = Meta-type info 00126 typedef ACE_Addr PEER_ADDR; 00127 00128 /// Dump the state of an object. 00129 void dump (void) const; 00130 00131 /// Declare the dynamic allocation hooks. 00132 ACE_ALLOC_HOOK_DECLARE; 00133 }; 00134 00135 #if !defined (ACE_LACKS_INLINE_FUNCTIONS) 00136 #include "ace/MEM_Stream.i" 00137 #endif /* ACE_LACKS_INLINE_FUNCTIONS */ 00138 00139 #endif /* ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1 */ 00140 00141 #include "ace/post.h" 00142 #endif /* ACE_MEM_STREAM_H */
1.2.14 written by Dimitri van Heesch,
© 1997-2002