#include <UPIPE_Stream.h>
Inheritance diagram for ACE_UPIPE_Stream:


Public Types | |
| typedef ACE_Stream< ACE_SYNCH > | MT_Stream |
| typedef ACE_UPIPE_Addr | PEER_ADDR |
Public Member Functions | |
| ACE_UPIPE_Stream (void) | |
| virtual | ~ACE_UPIPE_Stream (void) |
| int | close (void) |
| Shut down the UPIPE and release resources. | |
| ACE_HANDLE | get_handle (void) const |
| Return the underlying I/O handle. | |
| int | send (ACE_Message_Block *mb_p, ACE_Time_Value *timeout=0) |
| int | recv (ACE_Message_Block *&mb_p, ACE_Time_Value *timeout=0) |
| ssize_t | send (const char *buffer, size_t n, ACE_Time_Value *timeout=0) |
| ssize_t | recv (char *buffer, size_t n, ACE_Time_Value *timeout=0) |
| ssize_t | send_n (const char *buffer, size_t n, ACE_Time_Value *timeout=0) |
| ssize_t | recv_n (char *buffer, size_t n, ACE_Time_Value *timeout=0) |
| int | control (int cmd, void *val) const |
| Perform control operations on the UPIPE_Stream. | |
| int | get_remote_addr (ACE_UPIPE_Addr &remote_sap) const |
| Return the remote address we are connected to. | |
| void | dump (void) const |
| Dump the state of an object. | |
Public Attributes | |
| ACE_ALLOC_HOOK_DECLARE | |
| Declare the dynamic allocation hooks. | |
Private Attributes | |
| ACE_Message_Block * | mb_last_ |
| ACE_UPIPE_Addr | remote_addr_ |
| Address of who we are connected to. | |
| MT_Stream | stream_ |
| int | reference_count_ |
Friends | |
| class | ACE_UPIPE_Acceptor |
| class | ACE_UPIPE_Connector |
Definition at line 38 of file UPIPE_Stream.h.
|
|
Definition at line 44 of file UPIPE_Stream.h. |
|
|
Definition at line 107 of file UPIPE_Stream.h. |
|
|
Definition at line 19 of file UPIPE_Stream.cpp. References ACE_TRACE.
00020 : mb_last_ (0), 00021 reference_count_ (0) 00022 { 00023 ACE_TRACE ("ACE_UPIPE_Stream::ACE_UPIPE_STREAM"); 00024 } |
|
|
Definition at line 26 of file UPIPE_Stream.cpp. References mb_last_, and ACE_Message_Block::release().
|
|
|
Shut down the UPIPE and release resources.
Reimplemented from ACE_SPIPE. Definition at line 54 of file UPIPE_Stream.cpp. References ACE_GUARD_RETURN, ACE_TRACE, ACE_Stream<>::close(), ACE_SPIPE::close(), and ACE_IPC_SAP::get_handle().
00055 {
00056 ACE_TRACE ("ACE_UPIPE_Stream::close");
00057 ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1));
00058
00059 this->reference_count_--;
00060
00061 if (this->reference_count_ == 0)
00062 {
00063 // Since the UPIPE should have been closed earlier we won't bother
00064 // checking to see if closing it now fails.
00065
00066 if (this->ACE_SPIPE::get_handle () != ACE_INVALID_HANDLE)
00067 this->ACE_SPIPE::close ();
00068
00069 // Close down the ACE_stream.
00070 return this->stream_.close ();
00071 }
00072 return 0;
00073 }
|
|
||||||||||||
|
Perform control operations on the UPIPE_Stream.
Reimplemented from ACE_IPC_SAP. Definition at line 36 of file UPIPE_Stream.cpp. References ACE_IO_Cntl_Msg::ACE_IO_Cntl_Cmds, and ACE_TRACE.
00038 {
00039 ACE_TRACE ("ACE_UPIPE_Stream::control");
00040
00041 return ((ACE_UPIPE_Stream *) this)->stream_.control
00042 ((ACE_IO_Cntl_Msg::ACE_IO_Cntl_Cmds) cmd, val);
00043 }
|
|
|
Dump the state of an object.
Reimplemented from ACE_SPIPE. Definition at line 46 of file UPIPE_Stream.cpp. References ACE_TRACE.
00047 {
00048 #if defined (ACE_HAS_DUMP)
00049 ACE_TRACE ("ACE_UPIPE_Stream::dump");
00050 #endif /* ACE_HAS_DUMP */
00051 }
|
|
|
Return the underlying I/O handle.
Reimplemented from ACE_IPC_SAP. Definition at line 8 of file UPIPE_Stream.inl. References ACE_TRACE, and ACE_IPC_SAP::get_handle(). Referenced by ACE_UPIPE_Acceptor::accept(), and ACE_UPIPE_Connector::connect().
00009 {
00010 ACE_TRACE ("ACE_UPIPE_Stream::get_handle");
00011 return this->ACE_SPIPE::get_handle ();
00012 }
|
|
|
Return the remote address we are connected to.
Definition at line 76 of file UPIPE_Stream.cpp. References ACE_TRACE.
00077 {
00078 ACE_TRACE ("ACE_UPIPE_Stream::get_remote_addr");
00079 remote_sap = this->remote_addr_;
00080 return 0;
00081 }
|
|
||||||||||||||||
|
Recv a buffer of upto n bytes from the message queue. Returns -1 on error, else number of bytes read. Definition at line 120 of file UPIPE_Stream.cpp. References ACE_TRACE, EWOULDBLOCK, ACE_Stream<>::get(), ACE_Message_Block::length(), mb_last_, ACE_OS::memcpy(), ACE_Message_Block::rd_ptr(), and ACE_Message_Block::release().
00123 {
00124 ACE_TRACE ("ACE_UPIPE_Stream::recv");
00125 // Index in buffer.
00126 size_t bytes_read = 0;
00127
00128 while (bytes_read < n)
00129 if (this->mb_last_ != 0)
00130 {
00131 // We have remaining data in our last read Message_Buffer.
00132 size_t this_len = this->mb_last_->length ();
00133 if (this_len < n)
00134 {
00135 // The remaining data is not enough.
00136
00137 ACE_OS::memcpy ((void *) &buffer[bytes_read],
00138 this->mb_last_->rd_ptr (),
00139 this_len);
00140 bytes_read += this_len;
00141 this->mb_last_ = this->mb_last_->release (); // mb_last_ now 0
00142 return bytes_read;
00143 }
00144 else
00145 {
00146 // The remaining data is at least enough. If there's
00147 // more, we'll get it the next time through.
00148 ACE_OS::memcpy (&buffer[bytes_read],
00149 this->mb_last_->rd_ptr (),
00150 n);
00151 bytes_read += n;
00152
00153 // Advance rd_ptr.
00154 this->mb_last_->rd_ptr (n);
00155
00156 if (this->mb_last_->length () == 0)
00157 // Now the Message_Buffer is empty.
00158 this->mb_last_ = this->mb_last_->release ();
00159 }
00160 }
00161 else
00162 {
00163 // We have to get a new Message_Buffer from our stream.
00164 int result = this->stream_.get (this->mb_last_, timeout);
00165
00166 if (result == -1)
00167 {
00168 if (errno == EWOULDBLOCK && bytes_read > 0)
00169 // Return the number of bytes read before we timed out.
00170 return bytes_read;
00171 else
00172 return -1;
00173 }
00174 }
00175
00176 return bytes_read;
00177 }
|
|
||||||||||||
|
Recv a message from the message queue. Returns -1 on error, else 0. Definition at line 91 of file UPIPE_Stream.cpp. References ACE_Stream<>::get(). Referenced by ACE_UPIPE_Connector::connect(), and recv_n().
|
|
||||||||||||||||
|
Recv a buffer of exactly bytes from the message queue. Returns -1 on error, else the number of bytes read. Definition at line 205 of file UPIPE_Stream.cpp. References ACE_TRACE, recv(), and ssize_t.
00208 {
00209 ACE_TRACE ("ACE_UPIPE_Stream::recv_n");
00210 size_t bytes_read;
00211 ssize_t len = 0;
00212
00213 for (bytes_read = 0;
00214 bytes_read < n;
00215 bytes_read += len)
00216 {
00217 len = this->recv (buf + bytes_read,
00218 n - bytes_read,
00219 timeout);
00220 if (len == -1)
00221 return -1;
00222 else if (len == 0)
00223 break;
00224 }
00225
00226 return bytes_read;
00227 }
|
|
||||||||||||||||
|
Send a buffer of n bytes through the message queue. Returns -1 on error, else number of bytes sent. Definition at line 100 of file UPIPE_Stream.cpp. References ACE_NEW_RETURN, ACE_TRACE, ACE_Message_Block::copy(), and ACE_Stream<>::put().
00103 {
00104 ACE_TRACE ("ACE_UPIPE_Stream::send");
00105
00106 ACE_Message_Block *mb_p;
00107 ACE_NEW_RETURN (mb_p,
00108 ACE_Message_Block (n),
00109 -1);
00110 mb_p->copy (buffer, n);
00111 return
00112 this->stream_.put (mb_p, timeout) == -1
00113 ? -1
00114 : static_cast<ssize_t> (n);
00115 }
|
|
||||||||||||
|
Send a message through the message queue. Returns -1 on error, else 0. Definition at line 84 of file UPIPE_Stream.cpp. References ACE_TRACE, and ACE_Stream<>::put(). Referenced by ACE_UPIPE_Acceptor::accept(), and send_n().
|
|
||||||||||||||||
|
Send a buffer of exactly n bytes to the message queue. Returns -1 on error, else number of bytes written (which should == n). Definition at line 180 of file UPIPE_Stream.cpp. References ACE_TRACE, send(), and ssize_t.
00183 {
00184 ACE_TRACE ("ACE_UPIPE_Stream::send_n");
00185
00186 size_t bytes_written;
00187 ssize_t len = 0;
00188
00189 for (bytes_written = 0;
00190 bytes_written < n;
00191 bytes_written += len)
00192 {
00193 len = this->send (buf + bytes_written,
00194 n - bytes_written,
00195 timeout);
00196
00197 if (len == -1)
00198 return -1;
00199 }
00200
00201 return bytes_written;
00202 }
|
|
|
Definition at line 41 of file UPIPE_Stream.h. |
|
|
Definition at line 42 of file UPIPE_Stream.h. |
|
|
Declare the dynamic allocation hooks.
Reimplemented from ACE_SPIPE. Definition at line 104 of file UPIPE_Stream.h. |
|
|
To hold the last ACE_Message_Block read out of the stream. Thus allowing subsequent reads from one ACE_Message_Block Definition at line 112 of file UPIPE_Stream.h. Referenced by recv(), and ~ACE_UPIPE_Stream(). |
|
|
Keep track of whether the sender and receiver have both shut down. Definition at line 123 of file UPIPE_Stream.h. Referenced by ACE_UPIPE_Acceptor::accept(), and ACE_UPIPE_Connector::connect(). |
|
|
Address of who we are connected to.
Definition at line 115 of file UPIPE_Stream.h. Referenced by ACE_UPIPE_Acceptor::accept(), and ACE_UPIPE_Connector::connect(). |
|
|
Stream component used by the Definition at line 119 of file UPIPE_Stream.h. Referenced by ACE_UPIPE_Acceptor::accept(). |
1.3.6