diff options
author | parsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2008-08-06 18:21:48 +0000 |
---|---|---|
committer | parsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2008-08-06 18:21:48 +0000 |
commit | 09a2449f11bccb5f1eaeaccc0c300c1813d94655 (patch) | |
tree | c975d60466963e31072f1ed27dbcfce387cf02cd /ACE/examples/Connection | |
parent | e88999beef0d5bb108135f2fe442895aac704db8 (diff) | |
download | ATCD-09a2449f11bccb5f1eaeaccc0c300c1813d94655.tar.gz |
ChangeLogTag: Wed Aug 6 18:17:32 UTC 2008 Jeff Parsons <j.parsons@vanderbilt.edu>
Diffstat (limited to 'ACE/examples/Connection')
-rw-r--r-- | ACE/examples/Connection/blocking/SPIPE-connector.cpp | 52 |
1 files changed, 32 insertions, 20 deletions
diff --git a/ACE/examples/Connection/blocking/SPIPE-connector.cpp b/ACE/examples/Connection/blocking/SPIPE-connector.cpp index caa99901aac..9c6cd96735b 100644 --- a/ACE/examples/Connection/blocking/SPIPE-connector.cpp +++ b/ACE/examples/Connection/blocking/SPIPE-connector.cpp @@ -32,16 +32,21 @@ Peer_Handler::open (void *) if (iterations_ == 0) { this->display_menu (); - if (ACE_Event_Handler::register_stdin_handler - (this, - ACE_Reactor::instance (), - ACE_Thread_Manager::instance ()) == -1) - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("%p\n"), - ACE_TEXT ("register_stdin_handler")), - -1); + + if (ACE_Event_Handler::register_stdin_handler ( + this, + ACE_Reactor::instance (), + ACE_Thread_Manager::instance ()) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("register_stdin_handler")), + -1); + } else - return 0; + { + return 0; + } } else // If iterations_ has been set, send iterations_ buffers. { @@ -55,9 +60,10 @@ Peer_Handler::open (void *) int length = ACE_OS::strlen (buffer); while (iterations_-- > 0 - && this->peer ().send_n (buffer, - length) == length) - continue; + && this->peer ().send_n (buffer, length) == length) + { + continue; + } this->peer ().close (); ACE_Reactor::instance ()->end_reactor_event_loop(); @@ -77,17 +83,22 @@ Peer_Handler::handle_input (ACE_HANDLE) if (n > 0) { if (this->peer ().send (buf, n) != n) - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("%p\n"), - ACE_TEXT ("write failed")), - -1); + { + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("write failed")), + -1); + } else if (n == 0) // Explicitly close the connection. { if (this->peer ().close () == -1) - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("%p\n"), - ACE_TEXT ("close")), - 1); + { + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("close")), + 1); + } + return -1; } else @@ -95,6 +106,7 @@ Peer_Handler::handle_input (ACE_HANDLE) this->display_menu (); } } + return 0; } |