diff options
Diffstat (limited to 'examples/IPC_SAP/TLI_SAP/CPP-server.cpp')
-rw-r--r-- | examples/IPC_SAP/TLI_SAP/CPP-server.cpp | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/examples/IPC_SAP/TLI_SAP/CPP-server.cpp b/examples/IPC_SAP/TLI_SAP/CPP-server.cpp index 2cc3204a9a3..e5e0068c676 100644 --- a/examples/IPC_SAP/TLI_SAP/CPP-server.cpp +++ b/examples/IPC_SAP/TLI_SAP/CPP-server.cpp @@ -1,6 +1,7 @@ // $Id$ #include "ace/TLI_Acceptor.h" +#include "ace/INET_Addr.h" ACE_RCSID(TLI_SAP, CPP_server, "$Id$") @@ -9,18 +10,16 @@ ACE_RCSID(TLI_SAP, CPP_server, "$Id$") int main (int argc, char *argv[]) -{ +{ u_short port = argc > 1 ? ACE_OS::atoi (argv[1]) : ACE_DEFAULT_SERVER_PORT; ACE_Time_Value timeout (argc > 2 ? ACE_OS::atoi (argv[2]) : ACE_DEFAULT_TIMEOUT); // Create a server address. - ACE_INET_Addr addr (port); + ACE_INET_Addr addr (port); // Create a server, reuse the addr. ACE_TLI_Acceptor peer_acceptor; - // Not sure why but reuse_addr set to true/1 causes problems for - // FORE/XTI/ATM - this is now handled in ACE_TLI_Acceptor::open() if (peer_acceptor.open (addr, 1) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", @@ -30,8 +29,8 @@ main (int argc, char *argv[]) ACE_TLI_Stream new_stream; ACE_DEBUG ((LM_DEBUG, - "starting server at host %s\n", - addr.get_host_name ())); + "starting server at port %d\n", + addr.get_port_number ())); // Performs the iterative server activities @@ -42,8 +41,7 @@ main (int argc, char *argv[]) // Create a new ACE_TLI_Stream endpoint (note automatic restart // if errno == EINTR). if (peer_acceptor.accept (new_stream, - &addr, - &timeout) == -1) + &addr, &timeout) == -1) { ACE_ERROR ((LM_ERROR, "%p\n", @@ -52,16 +50,15 @@ main (int argc, char *argv[]) } ACE_DEBUG ((LM_DEBUG, - "client %s connected\n", - addr.get_host_name ())); + "client %s connected from %d\n", + addr.get_host_name (), + addr.get_port_number ())); // Read data from client (terminate on error). for (int r_bytes; (r_bytes = new_stream.recv (buf, sizeof buf)) > 0; ) - if (ACE_OS::write (ACE_STDOUT, - buf, - r_bytes) != r_bytes) + if (ACE_OS::write (ACE_STDOUT, buf, r_bytes) != r_bytes) ACE_ERROR ((LM_ERROR, "%p\n", "ACE::send_n")); |