diff options
Diffstat (limited to 'examples/IPC_SAP/TLI_SAP')
-rw-r--r-- | examples/IPC_SAP/TLI_SAP/CPP-client.cpp | 68 | ||||
-rw-r--r-- | examples/IPC_SAP/TLI_SAP/CPP-server.cpp | 68 | ||||
-rw-r--r-- | examples/IPC_SAP/TLI_SAP/Makefile | 201 | ||||
-rw-r--r-- | examples/IPC_SAP/TLI_SAP/db-client.cpp | 52 | ||||
-rw-r--r-- | examples/IPC_SAP/TLI_SAP/db-server.cpp | 111 | ||||
-rw-r--r-- | examples/IPC_SAP/TLI_SAP/ftp-client.cpp | 45 | ||||
-rw-r--r-- | examples/IPC_SAP/TLI_SAP/ftp-server.cpp | 75 | ||||
-rw-r--r-- | examples/IPC_SAP/TLI_SAP/signal_thread.c | 53 |
8 files changed, 0 insertions, 673 deletions
diff --git a/examples/IPC_SAP/TLI_SAP/CPP-client.cpp b/examples/IPC_SAP/TLI_SAP/CPP-client.cpp deleted file mode 100644 index cf491dff8fa..00000000000 --- a/examples/IPC_SAP/TLI_SAP/CPP-client.cpp +++ /dev/null @@ -1,68 +0,0 @@ - -// $Id$ - -#include "ace/TLI_Connector.h" -#include "ace/INET_Addr.h" -#include "ace/Time_Value.h" - -#if defined (ACE_HAS_TLI) - -/* ACE_TLI Client */ - -int main (int argc, char *argv[]) -{ - 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); - - ACE_DEBUG ((LM_DEBUG, "starting non-blocking connect\n")); - - // 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 (errno != EWOULDBLOCK) - ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "connection failed"), 1); - - ACE_DEBUG ((LM_DEBUG, "starting timed connect\n")); - - // Check if non-blocking connection is in progress, - // and wait up to timeout seconds for it to complete. - ACE_Time_Value tv (timeout); - - if (con.complete (cli_stream, &remote_addr, &tv) == -1) - ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "connection failed"), 1); - else - ACE_DEBUG ((LM_DEBUG, "connected to %s\n", - remote_addr.get_host_name ())); - } - - // 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) == -1) - ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "send_n"), 1); - - /* Explicitly close the connection */ - if (cli_stream.close () == -1) - ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "close"), -1); - - return 0; -} -#else -int main (void) -{ - ACE_ERROR_RETURN ((LM_ERROR, - "your platform must support ACE_TLI\n"), 1); -} -#endif /* ACE_HAS_TLI */ diff --git a/examples/IPC_SAP/TLI_SAP/CPP-server.cpp b/examples/IPC_SAP/TLI_SAP/CPP-server.cpp deleted file mode 100644 index a47023b3609..00000000000 --- a/examples/IPC_SAP/TLI_SAP/CPP-server.cpp +++ /dev/null @@ -1,68 +0,0 @@ - -// $Id$ - -#include "ace/TLI_Acceptor.h" -#include "ace/INET_Addr.h" - -#if defined (ACE_HAS_TLI) -/* ACE_TLI Server */ - -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); - - /* Create a server, reuse the addr. */ - ACE_TLI_Acceptor peer_acceptor; - - if (peer_acceptor.open (addr, 1) == -1) - ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), -1); - - ACE_TLI_Stream new_stream; - - ACE_DEBUG ((LM_DEBUG, "starting server at port %d\n", - addr.get_port_number ())); - - /* Performs the iterative server activities */ - - for (;;) - { - char buf[BUFSIZ]; - - /* Create a new ACE_TLI_Stream endpoint (note automatic restart - if errno == EINTR) */ - if (peer_acceptor.accept (new_stream, - &addr, &timeout) == -1) - { - ACE_ERROR ((LM_ERROR, "%p\n", "accept")); - continue; - } - - ACE_DEBUG ((LM_DEBUG, "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) - ACE_ERROR ((LM_ERROR, "%p\n", "ACE::send_n")); - - // Close new endpoint (listening endpoint stays open). - if (new_stream.close () == -1) - ACE_ERROR ((LM_ERROR, "%p\n", "close")); - - } - /* NOTREACHED */ - return 0; -} -#else -int main (void) -{ - ACE_ERROR_RETURN ((LM_ERROR, "your platform must support ACE_TLI\n"), 1); -} -#endif /* ACE_HAS_TLI */ diff --git a/examples/IPC_SAP/TLI_SAP/Makefile b/examples/IPC_SAP/TLI_SAP/Makefile deleted file mode 100644 index a5743d7ef36..00000000000 --- a/examples/IPC_SAP/TLI_SAP/Makefile +++ /dev/null @@ -1,201 +0,0 @@ -#---------------------------------------------------------------------------- -# @(#)Makefile 1.1 10/18/96 -# -# Makefile for TLI_SAP test -#---------------------------------------------------------------------------- - -#---------------------------------------------------------------------------- -# Local macros -#---------------------------------------------------------------------------- - -BIN = ftp-client \ - ftp-server \ - db-client \ - db-server \ - CPP-client \ - CPP-server - -LSRC = $(addsuffix .cpp,$(BIN)) - -LDLIBS= - -VLDLIBS = $(LDLIBS:%=%$(VAR)) - -BUILD = $(VBIN) - -INSTALL = - -#---------------------------------------------------------------------------- -# Include macros and targets -#---------------------------------------------------------------------------- - -include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU -include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU -include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU -include $(WRAPPER_ROOT)/include/makeinclude/rules.nonested.GNU -include $(WRAPPER_ROOT)/include/makeinclude/rules.bin.GNU -include $(WRAPPER_ROOT)/include/makeinclude/rules.local.GNU - -#---------------------------------------------------------------------------- -# Local targets -#---------------------------------------------------------------------------- - -#---------------------------------------------------------------------------- -# Dependencies -#---------------------------------------------------------------------------- - -# DO NOT DELETE THIS LINE -- g++dep uses it. -# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. - -.obj/ftp-client.o .shobj/ftp-client.so: ftp-client.cpp \ - $(WRAPPER_ROOT)/ace/TLI_Connector.h \ - $(WRAPPER_ROOT)/ace/TLI_Stream.h \ - $(WRAPPER_ROOT)/ace/TLI.h \ - $(WRAPPER_ROOT)/ace/IPC_SAP.h \ - $(WRAPPER_ROOT)/ace/ACE.h \ - $(WRAPPER_ROOT)/ace/OS.h \ - $(WRAPPER_ROOT)/ace/Time_Value.h \ - $(WRAPPER_ROOT)/ace/config.h \ - $(WRAPPER_ROOT)/ace/stdcpp.h \ - $(WRAPPER_ROOT)/ace/Trace.h \ - $(WRAPPER_ROOT)/ace/Log_Msg.h \ - $(WRAPPER_ROOT)/ace/Log_Record.h \ - $(WRAPPER_ROOT)/ace/Log_Priority.h \ - $(WRAPPER_ROOT)/ace/Log_Record.i \ - $(WRAPPER_ROOT)/ace/ACE.i \ - $(WRAPPER_ROOT)/ace/IPC_SAP.i \ - $(WRAPPER_ROOT)/ace/Addr.h \ - $(WRAPPER_ROOT)/ace/TLI.i \ - $(WRAPPER_ROOT)/ace/INET_Addr.h \ - $(WRAPPER_ROOT)/ace/TLI_Stream.i \ - $(WRAPPER_ROOT)/ace/TLI_Connector.i -.obj/ftp-server.o .shobj/ftp-server.so: ftp-server.cpp \ - $(WRAPPER_ROOT)/ace/Thread_Manager.h \ - $(WRAPPER_ROOT)/ace/Thread.h \ - $(WRAPPER_ROOT)/ace/ACE.h \ - $(WRAPPER_ROOT)/ace/OS.h \ - $(WRAPPER_ROOT)/ace/Time_Value.h \ - $(WRAPPER_ROOT)/ace/config.h \ - $(WRAPPER_ROOT)/ace/stdcpp.h \ - $(WRAPPER_ROOT)/ace/Trace.h \ - $(WRAPPER_ROOT)/ace/Log_Msg.h \ - $(WRAPPER_ROOT)/ace/Log_Record.h \ - $(WRAPPER_ROOT)/ace/Log_Priority.h \ - $(WRAPPER_ROOT)/ace/Log_Record.i \ - $(WRAPPER_ROOT)/ace/ACE.i \ - $(WRAPPER_ROOT)/ace/Synch.h \ - $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ - $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ - $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ - $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ - $(WRAPPER_ROOT)/ace/Synch_T.h \ - $(WRAPPER_ROOT)/ace/Event_Handler.h \ - $(WRAPPER_ROOT)/ace/TLI_Acceptor.h \ - $(WRAPPER_ROOT)/ace/TLI.h \ - $(WRAPPER_ROOT)/ace/IPC_SAP.h \ - $(WRAPPER_ROOT)/ace/IPC_SAP.i \ - $(WRAPPER_ROOT)/ace/Addr.h \ - $(WRAPPER_ROOT)/ace/TLI.i \ - $(WRAPPER_ROOT)/ace/TLI_Stream.h \ - $(WRAPPER_ROOT)/ace/INET_Addr.h \ - $(WRAPPER_ROOT)/ace/TLI_Stream.i \ - $(WRAPPER_ROOT)/ace/TLI_Acceptor.i -.obj/db-client.o .shobj/db-client.so: db-client.cpp \ - $(WRAPPER_ROOT)/ace/TLI_Connector.h \ - $(WRAPPER_ROOT)/ace/TLI_Stream.h \ - $(WRAPPER_ROOT)/ace/TLI.h \ - $(WRAPPER_ROOT)/ace/IPC_SAP.h \ - $(WRAPPER_ROOT)/ace/ACE.h \ - $(WRAPPER_ROOT)/ace/OS.h \ - $(WRAPPER_ROOT)/ace/Time_Value.h \ - $(WRAPPER_ROOT)/ace/config.h \ - $(WRAPPER_ROOT)/ace/stdcpp.h \ - $(WRAPPER_ROOT)/ace/Trace.h \ - $(WRAPPER_ROOT)/ace/Log_Msg.h \ - $(WRAPPER_ROOT)/ace/Log_Record.h \ - $(WRAPPER_ROOT)/ace/Log_Priority.h \ - $(WRAPPER_ROOT)/ace/Log_Record.i \ - $(WRAPPER_ROOT)/ace/ACE.i \ - $(WRAPPER_ROOT)/ace/IPC_SAP.i \ - $(WRAPPER_ROOT)/ace/Addr.h \ - $(WRAPPER_ROOT)/ace/TLI.i \ - $(WRAPPER_ROOT)/ace/INET_Addr.h \ - $(WRAPPER_ROOT)/ace/TLI_Stream.i \ - $(WRAPPER_ROOT)/ace/TLI_Connector.i -.obj/db-server.o .shobj/db-server.so: db-server.cpp \ - $(WRAPPER_ROOT)/ace/TLI_Acceptor.h \ - $(WRAPPER_ROOT)/ace/TLI.h \ - $(WRAPPER_ROOT)/ace/IPC_SAP.h \ - $(WRAPPER_ROOT)/ace/ACE.h \ - $(WRAPPER_ROOT)/ace/OS.h \ - $(WRAPPER_ROOT)/ace/Time_Value.h \ - $(WRAPPER_ROOT)/ace/config.h \ - $(WRAPPER_ROOT)/ace/stdcpp.h \ - $(WRAPPER_ROOT)/ace/Trace.h \ - $(WRAPPER_ROOT)/ace/Log_Msg.h \ - $(WRAPPER_ROOT)/ace/Log_Record.h \ - $(WRAPPER_ROOT)/ace/Log_Priority.h \ - $(WRAPPER_ROOT)/ace/Log_Record.i \ - $(WRAPPER_ROOT)/ace/ACE.i \ - $(WRAPPER_ROOT)/ace/IPC_SAP.i \ - $(WRAPPER_ROOT)/ace/Addr.h \ - $(WRAPPER_ROOT)/ace/TLI.i \ - $(WRAPPER_ROOT)/ace/TLI_Stream.h \ - $(WRAPPER_ROOT)/ace/INET_Addr.h \ - $(WRAPPER_ROOT)/ace/TLI_Stream.i \ - $(WRAPPER_ROOT)/ace/TLI_Acceptor.i \ - $(WRAPPER_ROOT)/ace/Thread_Manager.h \ - $(WRAPPER_ROOT)/ace/Thread.h \ - $(WRAPPER_ROOT)/ace/Synch.h \ - $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ - $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ - $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ - $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ - $(WRAPPER_ROOT)/ace/Synch_T.h \ - $(WRAPPER_ROOT)/ace/Event_Handler.h -.obj/CPP-client.o .shobj/CPP-client.so: CPP-client.cpp \ - $(WRAPPER_ROOT)/ace/TLI_Connector.h \ - $(WRAPPER_ROOT)/ace/TLI_Stream.h \ - $(WRAPPER_ROOT)/ace/TLI.h \ - $(WRAPPER_ROOT)/ace/IPC_SAP.h \ - $(WRAPPER_ROOT)/ace/ACE.h \ - $(WRAPPER_ROOT)/ace/OS.h \ - $(WRAPPER_ROOT)/ace/Time_Value.h \ - $(WRAPPER_ROOT)/ace/config.h \ - $(WRAPPER_ROOT)/ace/stdcpp.h \ - $(WRAPPER_ROOT)/ace/Trace.h \ - $(WRAPPER_ROOT)/ace/Log_Msg.h \ - $(WRAPPER_ROOT)/ace/Log_Record.h \ - $(WRAPPER_ROOT)/ace/Log_Priority.h \ - $(WRAPPER_ROOT)/ace/Log_Record.i \ - $(WRAPPER_ROOT)/ace/ACE.i \ - $(WRAPPER_ROOT)/ace/IPC_SAP.i \ - $(WRAPPER_ROOT)/ace/Addr.h \ - $(WRAPPER_ROOT)/ace/TLI.i \ - $(WRAPPER_ROOT)/ace/INET_Addr.h \ - $(WRAPPER_ROOT)/ace/TLI_Stream.i \ - $(WRAPPER_ROOT)/ace/TLI_Connector.i -.obj/CPP-server.o .shobj/CPP-server.so: CPP-server.cpp \ - $(WRAPPER_ROOT)/ace/TLI_Acceptor.h \ - $(WRAPPER_ROOT)/ace/TLI.h \ - $(WRAPPER_ROOT)/ace/IPC_SAP.h \ - $(WRAPPER_ROOT)/ace/ACE.h \ - $(WRAPPER_ROOT)/ace/OS.h \ - $(WRAPPER_ROOT)/ace/Time_Value.h \ - $(WRAPPER_ROOT)/ace/config.h \ - $(WRAPPER_ROOT)/ace/stdcpp.h \ - $(WRAPPER_ROOT)/ace/Trace.h \ - $(WRAPPER_ROOT)/ace/Log_Msg.h \ - $(WRAPPER_ROOT)/ace/Log_Record.h \ - $(WRAPPER_ROOT)/ace/Log_Priority.h \ - $(WRAPPER_ROOT)/ace/Log_Record.i \ - $(WRAPPER_ROOT)/ace/ACE.i \ - $(WRAPPER_ROOT)/ace/IPC_SAP.i \ - $(WRAPPER_ROOT)/ace/Addr.h \ - $(WRAPPER_ROOT)/ace/TLI.i \ - $(WRAPPER_ROOT)/ace/TLI_Stream.h \ - $(WRAPPER_ROOT)/ace/INET_Addr.h \ - $(WRAPPER_ROOT)/ace/TLI_Stream.i \ - $(WRAPPER_ROOT)/ace/TLI_Acceptor.i - -# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/examples/IPC_SAP/TLI_SAP/db-client.cpp b/examples/IPC_SAP/TLI_SAP/db-client.cpp deleted file mode 100644 index 4e37630b43d..00000000000 --- a/examples/IPC_SAP/TLI_SAP/db-client.cpp +++ /dev/null @@ -1,52 +0,0 @@ - -// $Id$ - -#include "ace/TLI_Connector.h" - -#if defined (ACE_HAS_TLI) -const int MAXLINE = 255; - -int -main (int argc, char *argv[]) -{ - if (argc < 2) - ACE_ERROR_RETURN ((LM_ERROR, "Usage: %s employee_id [server-host port-number]\n", - argv[0]), -1); - - const char *emp_num = argv[1]; - const char *host_name = argc < 3 ? ACE_DEFAULT_SERVER_HOST : argv[2]; - unsigned short port = argc < 4 ? ACE_DEFAULT_SERVER_PORT : ACE_OS::atoi (argv[3]); - int n; - char buf[MAXLINE]; - - ACE_TLI_Stream client; - ACE_TLI_Connector con; - - if (con.connect (client, ACE_INET_Addr (port, host_name)) == -1) - ACE_OS::t_error ((char *)host_name), ACE_OS::exit (1); - - ACE_OS::strcpy (buf, emp_num); - n = ACE_OS::strlen (buf); - - if (client.send_n (buf, n) != n) - ACE_OS::t_error ("client.send error"); - - if (client.recv (buf, MAXLINE) == -1 && t_errno != TLOOK && client.look () != T_DISCONNECT) - ACE_OS::t_error ("client.recv error"); - - if (ACE_OS::strcmp (buf, "ERROR") == 0) - ACE_OS::printf ("Employee ID %s not in database\n", emp_num); - else - ACE_OS::printf ("Employee name requested is: %s\n", buf); - - if (client.close () == -1) - ACE_OS::t_error ("cli_close"), ACE_OS::exit (1); - - return 0; -} -#else -int main (void) -{ - ACE_ERROR_RETURN ((LM_ERROR, "your platform must support ACE_TLI\n"), 1); -} -#endif /* ACE_HAS_TLI */ diff --git a/examples/IPC_SAP/TLI_SAP/db-server.cpp b/examples/IPC_SAP/TLI_SAP/db-server.cpp deleted file mode 100644 index 83cf8d1e31a..00000000000 --- a/examples/IPC_SAP/TLI_SAP/db-server.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/* Simple multi-threaded database server example. */ -// $Id$ - - -#include "ace/TLI_Acceptor.h" -#include "ace/Thread_Manager.h" - -#if defined (ACE_HAS_THREADS) && defined (ACE_HAS_TLI) - -/* Global thread manager. */ -ACE_Thread_Manager thr_mgr; - -void * -lookup_name (ACE_HANDLE handle) -{ - ACE_Thread_Control tc (&thr_mgr); - - enum - { - MAXLINE = 255, - EMPNAMELEN = 512 - }; - - static struct - { - int emp_id; - const char emp_name[EMPNAMELEN]; - } employee_db[] = - { - {123, "John Wayne Bobbit"}, - {124, "Cindy Crawford"}, - {125, "O. J. Simpson"}, - {126, "Bill Clinton"}, - {127, "Rush Limbaugh"}, - {128, "Michael Jackson"}, - {129, "George Burns"}, - {130, "Paula Jones"}, - {0, ""} - }; - - int n; - int flags; - int len; - int employee_id; - int index; - int found; - ACE_TLI_Stream stream; - char recvline[MAXLINE]; - char sendline[MAXLINE]; - - ACE_DEBUG ((LM_DEBUG, "stream handle = %d, thread id = %t\n", handle)); - stream.set_handle (handle); - - if ((n = stream.recv (recvline, MAXLINE, &flags)) == -1) - ACE_OS::t_error ("stream.recv error"); - - employee_id = ACE_OS::atoi (recvline); - found = 0; - - for (index = 0; found == 0 && employee_db[index].emp_id; index++) - if (employee_id == employee_db[index].emp_id) - { - found = 1; - n = ACE_OS::sprintf (sendline, "%s", employee_db[index].emp_name); - } - - if (found == 0) - n = ACE_OS::sprintf (sendline, "%s", "ERROR"); - - if ((len = stream.send (sendline, n + 1, 0)) == -1) - ACE_OS::t_error ("stream.send error"); - - if (stream.sndrel () == -1) - ACE_OS::t_error ("stream.send error"); - - if (stream.close () == -1) - ACE_OS::t_error ("stream.close error"); - - return 0; -} - -int -main (int argc, char *argv[]) -{ - u_short port = argc > 1 ? ACE_OS::atoi (argv[1]) : ACE_DEFAULT_SERVER_PORT; - ACE_INET_Addr l_addr (port); - ACE_TLI_Acceptor server (l_addr, 1); // Create server, reuse addr if in use. - ACE_TLI_Stream new_stream; - - // Wait for a connection from a client. This is an example of a - // concurrent server. - - for (;;) - { - if (server.accept (new_stream) == -1) - ::t_error ("server.accept error"); - - if (thr_mgr.spawn (ACE_THR_FUNC (lookup_name), - (void *) new_stream.get_handle (), - THR_DETACHED) == -1) - ACE_DEBUG ((LM_ERROR, "server: can't create worker thread %d\n")); - } - return 0; -} -#else -#include <stdio.h> -int main (void) -{ - ACE_ERROR_RETURN ((LM_ERROR, "your platform must support ACE_TLI\n"), 1); -} -#endif /* ACE_HAS_THREADS */ diff --git a/examples/IPC_SAP/TLI_SAP/ftp-client.cpp b/examples/IPC_SAP/TLI_SAP/ftp-client.cpp deleted file mode 100644 index ae5bdece3f5..00000000000 --- a/examples/IPC_SAP/TLI_SAP/ftp-client.cpp +++ /dev/null @@ -1,45 +0,0 @@ - -// $Id$ - -#include "ace/TLI_Connector.h" - -#if defined (ACE_HAS_TLI) - -const int MAXLINE = 255; - -int -main (int argc, char *argv[]) -{ - if (argc < 2) - ACE_OS::fprintf (stderr, "Usage: %s filename [server-host port-number]\n", argv[0]), ACE_OS::exit (1); - - const char *filename = argv[1]; - const char *host_name = argc < 3 ? ACE_DEFAULT_SERVER_HOST : argv[2]; - unsigned short port = argc < 4 ? ACE_DEFAULT_SERVER_PORT : ACE_OS::atoi (argv[3]); - - ACE_TLI_Stream client; - ACE_TLI_Connector con; - int fd; - char buf[BUFSIZ]; - - if (con.connect (client, ACE_INET_Addr (port, host_name)) == -1) - ACE_OS::t_error ((char *) host_name), ACE_OS::exit (1); - - if ((fd = ACE_OS::open (filename, O_RDONLY)) == -1) - ACE_OS::perror (filename), ACE_OS::exit (1); - - for (int n; (n = ACE_OS::read (fd, buf, sizeof buf)) > 0; ) - if (client.send_n (buf, n) != n) - ACE_OS::t_error ("client.send error"); - - if (client.close () == -1) - ACE_OS::t_error ("cli_close"), ACE_OS::exit (1); - - return 0; -} -#else -int main (void) -{ - ACE_ERROR_RETURN ((LM_ERROR, "your platform does not support ACE_TLI\n"), 1); -} -#endif /* ACE_HAS_TLI */ diff --git a/examples/IPC_SAP/TLI_SAP/ftp-server.cpp b/examples/IPC_SAP/TLI_SAP/ftp-server.cpp deleted file mode 100644 index 046f4dc0464..00000000000 --- a/examples/IPC_SAP/TLI_SAP/ftp-server.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* Simple file transfer example */ -// $Id$ - - -#include "ace/Thread_Manager.h" -#include "ace/TLI_Acceptor.h" - -#if defined (ACE_HAS_THREADS) && defined (ACE_HAS_TLI) - -ACE_Thread_Manager thr_mgr; - -void * -read_file (void *fd) -{ - ACE_Thread_Control tc (&thr_mgr); - ACE_TLI_Stream stream; - char buf[BUFSIZ]; - int flags = 0; - int n; - - stream.set_handle (int (fd)); - - ACE_OS::printf ("start (tid = %d, fd = %d)\n", ACE_OS::thr_self (), stream.get_handle ()); - ACE_OS::fflush (stdout); - - while ((n = stream.recv (buf, sizeof buf, &flags)) > 0) - continue; - - ACE_OS::printf ("finish (tid = %d, fd = %d)\n", ACE_OS::thr_self (), stream.get_handle ()); - - if (stream.close () == -1) - ACE_OS::t_error ("stream.close error"); - - return 0; -} - -int -main (int argc, char *argv[]) -{ - u_short port = argc > 1 ? ACE_OS::atoi (argv[1]) : ACE_DEFAULT_SERVER_PORT; - ACE_TLI_Acceptor server; - ACE_TLI_Stream new_stream; - - /* Allow up to 100 simultaneous threads */ - if (thr_mgr.open (100) == -1) - ACE_OS::perror ("thr_mgr.open"), ACE_OS::exit (1); - - // Open the server and reuse the address if in use... - if (server.open (ACE_INET_Addr (port), 1) == -1) - ACE_OS::t_error ("server.open"), ACE_OS::exit (1); - - /* Wait for a connection from a client. This is an example of a concurrent server */ - - for (int count = 1; ; count++) - { - ACE_OS::fprintf (stderr, "thread %d, blocking for accept #%d\n", - ACE_OS::thr_self (), count); - - if (server.accept (new_stream) == -1) - ACE_OS::t_error ("server.accept error"); - - else if (thr_mgr.spawn (ACE_THR_FUNC (read_file), - (void *) new_stream.get_handle (), - THR_DETACHED | THR_BOUND) == -1) - ACE_OS::perror ("can't create worker thread\n"); - } - return 0; -} -#else -#include <stdio.h> -int main (void) -{ - ACE_ERROR_RETURN ((LM_ERROR, "your platform must support ACE_TLI\n"), 1); -} -#endif /* ACE_HAS_THREADS */ diff --git a/examples/IPC_SAP/TLI_SAP/signal_thread.c b/examples/IPC_SAP/TLI_SAP/signal_thread.c deleted file mode 100644 index e3a3485f1a2..00000000000 --- a/examples/IPC_SAP/TLI_SAP/signal_thread.c +++ /dev/null @@ -1,53 +0,0 @@ -#define _REENTRANT -// @(#)signal_thread.c 1.1 10/18/96 - -#include <stdio.h> -#include <stdlib.h> -#include <signal.h> -#include <thread.h> -#include <synch.h> -#include <unistd.h> - -void *handle (v) - void *v; -{ - sigset_t set; - - sigemptyset (&set); - sigaddset (&set, SIGINT); - - for (;;) - if (sigwait (&set) != SIGINT) - perror ("sigwait"), exit (1); - else - fprintf (stderr, "got sigint!\n"); -} - -int -main (void) -{ - int retval; - sigset_t set; - thread_t t_id; - - sigemptyset (&set); - sigaddset (&set, SIGINT); - - if (sigprocmask (SIG_BLOCK, &set, 0) == -1) - perror ("sigprocmask"), exit (1); - - if (thr_sigsetmask (SIG_BLOCK, &set, 0) == -1) - perror ("sigprocmask"), exit (1); - - if (thr_create (0, 0, handle, 0, THR_DETACHED, &t_id) != 0) - perror ("thr_create"), exit (1); - - for (;;) - { - fprintf (stderr, "blocking for read in thread\n"); - if (read (0, &retval, sizeof retval) != sizeof retval) - perror ("read"); - } - fprintf (stderr, "I'm exiting!\n"); - return 0; -} |