Merge pull request #2216 from jwillemsen/jwi-cxxversionchecks
[ACE_TAO.git] / TAO / tao / Strategies / UIOP_Transport.cpp
blobff778763cc38adf6a1f5ab98e6bceef7c847d243
1 #include "tao/Strategies/UIOP_Transport.h"
3 #if TAO_HAS_UIOP == 1
5 #include "tao/Strategies/UIOP_Connection_Handler.h"
6 #include "tao/Strategies/UIOP_Profile.h"
7 #include "tao/Timeprobe.h"
8 #include "tao/CDR.h"
9 #include "tao/Transport_Mux_Strategy.h"
10 #include "tao/Wait_Strategy.h"
11 #include "tao/Stub.h"
12 #include "tao/ORB_Core.h"
13 #include "tao/debug.h"
14 #include "tao/GIOP_Message_Base.h"
16 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
18 TAO_UIOP_Transport::TAO_UIOP_Transport (TAO_UIOP_Connection_Handler *handler,
19 TAO_ORB_Core *orb_core)
20 : TAO_Transport (TAO_TAG_UIOP_PROFILE,
21 orb_core)
22 , connection_handler_ (handler)
26 TAO_UIOP_Transport::~TAO_UIOP_Transport ()
30 ACE_Event_Handler *
31 TAO_UIOP_Transport::event_handler_i ()
33 return this->connection_handler_;
36 TAO_Connection_Handler *
37 TAO_UIOP_Transport::connection_handler_i ()
39 return this->connection_handler_;
42 ssize_t
43 TAO_UIOP_Transport::send (iovec *iov, int iovcnt,
44 size_t &bytes_transferred,
45 const ACE_Time_Value *max_wait_time)
47 ssize_t const retval =
48 this->connection_handler_->peer ().sendv (iov, iovcnt, max_wait_time);
50 if (retval > 0)
51 bytes_transferred = retval;
53 return retval;
56 ssize_t
57 TAO_UIOP_Transport::recv (char *buf,
58 size_t len,
59 const ACE_Time_Value *max_wait_time)
61 const ssize_t n = this->connection_handler_->peer ().recv (buf,
62 len,
63 max_wait_time);
65 // Most of the errors handling is common for
66 // Now the message has been read
67 if (n == -1 &&
68 TAO_debug_level > 4 &&
69 errno != ETIME)
71 TAOLIB_DEBUG ((LM_DEBUG,
72 ACE_TEXT ("TAO (%P|%t) - UIOP_Transport::recv, %p %p\n"),
73 ACE_TEXT ("TAO - read message failure ")
74 ACE_TEXT ("recv ()\n")));
77 // Error handling
78 if (n == -1)
80 if (errno == EWOULDBLOCK)
81 return 0;
83 return -1;
85 // @@ What are the other error handling here??
86 else if (n == 0)
88 return -1;
91 return n;
94 int
95 TAO_UIOP_Transport::send_request (TAO_Stub *stub,
96 TAO_ORB_Core *orb_core,
97 TAO_OutputCDR &stream,
98 TAO_Message_Semantics message_semantics,
99 ACE_Time_Value *max_wait_time)
101 if (this->ws_->sending_request (orb_core, message_semantics) == -1)
103 return -1;
106 if (this->send_message (stream, stub, 0, message_semantics, max_wait_time) == -1)
108 return -1;
111 this->first_request_sent();
113 return 0;
117 TAO_UIOP_Transport::send_message (TAO_OutputCDR &stream,
118 TAO_Stub *stub,
119 TAO_ServerRequest *request,
120 TAO_Message_Semantics message_semantics,
121 ACE_Time_Value *max_wait_time)
123 // Format the message in the stream first
124 if (this->messaging_object ()->format_message (stream, stub, request) != 0)
126 return -1;
129 // Strictly speaking, should not need to loop here because the
130 // socket never gets set to a nonblocking mode ... some Linux
131 // versions seem to need it though. Leaving it costs little.
133 // This guarantees to send all data (bytes) or return an error.
134 const ssize_t n = this->send_message_shared (stub,
135 message_semantics,
136 stream.begin (),
137 max_wait_time);
139 if (n == -1)
141 if (TAO_debug_level)
142 TAOLIB_DEBUG ((LM_DEBUG,
143 ACE_TEXT ("TAO (%P|%t) closing transport %d after fault %p\n"),
144 this->id (),
145 ACE_TEXT ("send_message ()\n")));
147 return -1;
150 return 1;
153 TAO_END_VERSIONED_NAMESPACE_DECL
155 #endif /* TAO_HAS_UIOP */