3 //=============================================================================
7 * @author Nanbor Wang <nanbor@cs.wustl.edu>
9 //=============================================================================
12 #ifndef ACE_MEM_STREAM_H
13 #define ACE_MEM_STREAM_H
15 #include /**/ "ace/pre.h"
17 #include /**/ "ace/ACE_export.h"
19 #include "ace/MEM_IO.h"
21 #if !defined (ACE_LACKS_PRAGMA_ONCE)
23 #endif /* ACE_LACKS_PRAGMA_ONCE */
25 #if (ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1)
27 #include "ace/INET_Addr.h"
29 #if !defined (ACE_MEM_STREAM_MIN_BUFFER)
30 # define ACE_MEM_STREAM_MIN_BUFFER 4096
31 #endif /* ACE_MEM_STREAM_MIN_BUFFER */
33 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
35 class ACE_MEM_Acceptor
;
36 class ACE_MEM_Connector
;
39 * @class ACE_MEM_Stream
41 * @brief Defines the methods in the ACE_MEM_Stream abstraction.
43 * This adds additional wrapper methods atop the ACE_MEM_IO
44 * class. Notice that ACE_MEM_Stream can only send messages no bigger
45 * than the underlying MMAP file size minus sizeof (ACE_MEM_SAP_Node).
46 * The size of the MMAP file is default to ACE_MEM_STREAM_MIN_BUFFER.
47 * (Define above in this file, to 4096 bytes.)
48 * If you need to increase the size of allowable message
49 * ACE_MEM_Stream can handle, you can set it to either
50 * @c ACE_MEM_Acceptor::malloc_options(). minimal_bytes_
51 * @c ACE_MEM_Acceptor::init_buffer_size (size_t size);
52 * before establishing a connection.
54 class ACE_Export ACE_MEM_Stream
: public ACE_MEM_IO
57 friend class ACE_MEM_Acceptor
;
58 friend class ACE_MEM_Connector
;
60 // Initialization and termination methods.
64 /// Constructor (sets the underlying ACE_HANDLE with <h>).
65 ACE_MEM_Stream (ACE_HANDLE h
);
70 //= The following two methods use write and read system calls.
71 /// Send n bytes, keep trying until n are sent.
72 /// Recv n bytes, keep trying until n are received.
73 ssize_t
send_n (const void *buf
, size_t n
);
74 ssize_t
recv_n (void *buf
, size_t n
);
76 // = The following two methods use the send and recv system calls.
77 /// Send n bytes, keep trying until n are sent.
78 /// Recv n bytes, keep trying until n are received.
79 ssize_t
send_n (const void *buf
, size_t n
, int flags
);
80 ssize_t
recv_n (void *buf
, size_t n
, int flags
);
82 // = Selectively close endpoints.
84 /// Close down the reader.
87 /// Close down the writer.
91 * Close down the socket (we need this to make things work correctly
92 * on Win32, which requires use to do a <close_writer> before doing
93 * the close to avoid losing data).
98 typedef ACE_Addr PEER_ADDR
;
100 /// Dump the state of an object.
103 /// Declare the dynamic allocation hooks.
104 ACE_ALLOC_HOOK_DECLARE
;
107 ACE_END_VERSIONED_NAMESPACE_DECL
109 #if defined (__ACE_INLINE__)
110 #include "ace/MEM_Stream.inl"
111 #endif /* __ACE_INLINE__ */
113 #endif /* ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1 */
115 #include /**/ "ace/post.h"
116 #endif /* ACE_MEM_STREAM_H */