7 #include "jaws3/Jaws_IO.h"
8 #include "jaws3/Synch_IO.h"
9 #include "jaws3/Event_Completer.h"
11 static JAWS_Event_Result
12 JAWS_synch_send ( ACE_HANDLE handle
13 , ACE_Message_Block
*mb
14 , const ACE_Time_Value
*tv
= 0
17 JAWS_Event_Result io_result
;
19 ssize_t result
= ACE::send_n (handle
, mb
->rd_ptr (), mb
->length (), tv
);
24 JAWS_Event_Result
tmp_io_result ( 0
25 , JAWS_Event_Result::JE_ERROR
26 , JAWS_Event_Result::JE_SEND_TIMEOUT
28 io_result
= tmp_io_result
;
32 JAWS_Event_Result
tmp_io_result ( 0
33 , JAWS_Event_Result::JE_ERROR
34 , JAWS_Event_Result::JE_SEND_FAIL
36 io_result
= tmp_io_result
;
39 else if ((size_t) result
< mb
->length ())
44 JAWS_Event_Result
tmp_io_result ( result
45 , JAWS_Event_Result::JE_ERROR
46 , JAWS_Event_Result::JE_SEND_SHORT
48 io_result
= tmp_io_result
;
55 JAWS_Event_Result
tmp_io_result ( result
56 , JAWS_Event_Result::JE_OK
57 , JAWS_Event_Result::JE_SEND_OK
59 io_result
= tmp_io_result
;
66 JAWS_Synch_IO::send ( ACE_HANDLE handle
67 , ACE_Message_Block
*mb
68 , JAWS_Event_Completer
*completer
69 , const ACE_Time_Value
&tv
73 JAWS_Event_Result io_result
;
74 const ACE_Time_Value
*tvp
= 0;
76 if (ACE_Time_Value::zero
< tv
)
79 io_result
= JAWS_synch_send (handle
, mb
, tvp
);
82 completer
->output_complete (io_result
, act
);
87 JAWS_Synch_IO::send ( ACE_HANDLE handle
88 , ACE_Message_Block
*mb
89 , JAWS_Event_Completer
*completer
93 this->send (handle
, mb
, completer
, ACE_Time_Value::zero
, act
);
98 JAWS_Synch_IO::recv ( ACE_HANDLE handle
99 , ACE_Message_Block
*mb
100 , JAWS_Event_Completer
*completer
101 , const ACE_Time_Value
&tv
105 JAWS_Event_Result io_result
;
106 const ACE_Time_Value
*tvp
= 0;
108 if (ACE_Time_Value::zero
< tv
)
111 ssize_t result
= ACE::recv (handle
, mb
->wr_ptr (), mb
->space (), tvp
);
114 JAWS_Event_Result
tmp_io_result ( 0
115 , JAWS_Event_Result::JE_ERROR
116 , JAWS_Event_Result::JE_RECV_FAIL
118 io_result
= tmp_io_result
;
125 JAWS_Event_Result
tmp_io_result ( result
126 , JAWS_Event_Result::JE_OK
127 , JAWS_Event_Result::JE_RECV_OK
129 io_result
= tmp_io_result
;
133 completer
->input_complete (io_result
, act
);
138 JAWS_Synch_IO::recv ( ACE_HANDLE handle
139 , ACE_Message_Block
*mb
140 , JAWS_Event_Completer
*completer
144 this->recv (handle
, mb
, completer
, ACE_Time_Value::zero
, act
);
149 JAWS_Synch_IO::transmit ( ACE_HANDLE handle
151 , JAWS_Event_Completer
*completer
152 , const ACE_Time_Value
&tv
154 , ACE_Message_Block
*header
155 , ACE_Message_Block
*trailer
158 JAWS_Event_Result io_result
;
159 const ACE_Time_Value
*tvp
= 0;
161 if (ACE_Time_Value::zero
< tv
)
168 io_result
= JAWS_synch_send (handle
, header
, tvp
);
169 bytes
+= io_result
.bytes ();
170 if (io_result
.status () != JAWS_Event_Result::JE_OK
)
173 completer
->input_complete (io_result
, act
);
179 ACE_Message_Block
buf (8 * 1024);
181 while ((len
= ACE::recv (source
, buf
.wr_ptr (), buf
.space (), tvp
)) >= 0)
187 io_result
= JAWS_synch_send (handle
, & buf
);
188 bytes
+= io_result
.bytes ();
189 if (io_result
.status () != JAWS_Event_Result::JE_OK
)
191 JAWS_Event_Result
tmp_io_result ( bytes
192 , JAWS_Event_Result::JE_ERROR
193 , JAWS_Event_Result::JE_SEND_SHORT
197 completer
->input_complete (tmp_io_result
, act
);
207 io_result
= JAWS_synch_send (handle
, trailer
, tvp
);
208 bytes
+= io_result
.bytes ();
209 if (io_result
.status () != JAWS_Event_Result::JE_OK
)
211 JAWS_Event_Result
tmp_io_result ( bytes
212 , JAWS_Event_Result::JE_ERROR
213 , JAWS_Event_Result::JE_SEND_SHORT
217 completer
->input_complete (tmp_io_result
, act
);
225 JAWS_Event_Result
tmp_io_result ( bytes
226 , JAWS_Event_Result::JE_OK
227 , JAWS_Event_Result::JE_SEND_OK
229 io_result
= tmp_io_result
;
233 JAWS_Event_Result
tmp_io_result ( bytes
234 , JAWS_Event_Result::JE_ERROR
235 , JAWS_Event_Result::JE_SEND_SHORT
237 io_result
= tmp_io_result
;
241 completer
->input_complete (io_result
, act
);
246 JAWS_Synch_IO::transmit ( ACE_HANDLE handle
248 , JAWS_Event_Completer
*completer
250 , ACE_Message_Block
*header
251 , ACE_Message_Block
*trailer
254 this->transmit ( handle
257 , ACE_Time_Value::zero