diff options
Diffstat (limited to 'examples/IPC_SAP/TLI_SAP/CPP-client.cpp')
-rw-r--r-- | examples/IPC_SAP/TLI_SAP/CPP-client.cpp | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/examples/IPC_SAP/TLI_SAP/CPP-client.cpp b/examples/IPC_SAP/TLI_SAP/CPP-client.cpp index c02f576b701..2a0dbc9dc01 100644 --- a/examples/IPC_SAP/TLI_SAP/CPP-client.cpp +++ b/examples/IPC_SAP/TLI_SAP/CPP-client.cpp @@ -1,25 +1,23 @@ // $Id$ #include "ace/TLI_Connector.h" -#include "ace/INET_Addr.h" +#include "ace/INET_Addr.h" ACE_RCSID(TLI_SAP, CPP_client, "$Id$") #if defined (ACE_HAS_TLI) /* ACE_TLI Client */ - + int main (int argc, char *argv[]) -{ +{ const char *host = argc > 1 ? argv[1] : ACE_DEFAULT_SERVER_HOST; u_short r_port = argc > 2 ? ACE_OS::atoi (argv[2]) : ACE_DEFAULT_SERVER_PORT; int timeout = argc > 3 ? ACE_OS::atoi (argv[3]) : ACE_DEFAULT_TIMEOUT; u_short l_port = argc > 4 ? ACE_OS::atoi (argv[4]) : ACE_DEFAULT_LOCAL_PORT; - char buf[BUFSIZ]; ACE_TLI_Stream cli_stream; - ACE_INET_Addr remote_addr (r_port, host); ACE_INET_Addr local_addr (l_port); @@ -29,11 +27,9 @@ int main (int argc, char *argv[]) // Initiate timed, non-blocking connection with server. ACE_TLI_Connector con; - if (con.connect (cli_stream, - remote_addr, - (ACE_Time_Value *) &ACE_Time_Value::zero, - local_addr, - 1) == -1) + if (con.connect (cli_stream, remote_addr, + (ACE_Time_Value *) &ACE_Time_Value::zero, + local_addr, 1) == -1) { if (errno != EWOULDBLOCK) ACE_ERROR_RETURN ((LM_ERROR, @@ -48,13 +44,10 @@ int main (int argc, char *argv[]) // to timeout seconds for it to complete. ACE_Time_Value tv (timeout); - if (con.complete (cli_stream, - &remote_addr, - &tv) == -1) + if (con.complete (cli_stream, &remote_addr, &tv) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", - "connection failed"), - 1); + "connection failed"), 1); else ACE_DEBUG ((LM_DEBUG, "connected to %s\n", @@ -64,22 +57,20 @@ int main (int argc, char *argv[]) // Send data to server (correctly handles "incomplete writes"). for (int r_bytes; - (r_bytes = ACE_OS::read (ACE_STDIN, buf, sizeof buf)) > 0; - ) - if (cli_stream.send_n (buf, - r_bytes, - 0) == -1) + (r_bytes = ACE_OS::read (ACE_STDIN, buf, sizeof buf)) > 0; ) + if (cli_stream.send_n (buf, r_bytes) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "send_n"), 1); - // Explicitly close the connection. + /* Explicitly close the connection */ if (cli_stream.close () == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "close"), -1); + return 0; } #else |