2 * @file Threaded_Client.cpp
3 * @author Will Otte <wotte@dre.vanderbilt.edu>
5 * This program spawns two threads:
6 * 1.) A "server" thread using Server_Task that acts as a server meant to
7 * recieve forwarded requests.
8 * 2.) A "client" thread using Client_Task that acts as a client that sends
9 * a get_thread_id request that is forwarded by a remote server to
10 * the server in thread (1).
12 * The test passes if the thread id of the thread that services the get_thread_id
13 * request is the same as the thread that makes the request.
16 #include "Server_Task.h"
17 #include "Client_Task.h"
18 #include "ace/Get_Opt.h"
19 #include "ace/Argv_Type_Converter.h"
20 #include "ace/Manual_Event.h"
22 const ACE_TCHAR
*ior_input_file
= ACE_TEXT("test.ior");
23 const ACE_TCHAR
*ior_output_file
= ACE_TEXT("thr_server.ior");
26 parse_args (int argc
, ACE_TCHAR
*argv
[])
28 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("i:o:"));
31 while ((c
= get_opts ()) != -1)
35 ior_input_file
= get_opts
.opt_arg ();
38 ior_output_file
= get_opts
.opt_arg ();
42 ACE_ERROR_RETURN ((LM_ERROR
,
44 "-i alternate_remote_ior "
45 "-o alternate_local_ior "
55 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
59 ACE_Argv_Type_Converter
main_args_s (argc
, argv
);
62 CORBA::ORB_init (main_args_s
.get_argc (),
63 main_args_s
.get_TCHAR_argv (),
66 if (parse_args (argc
, argv
) == -1)
73 Server_Task
server_task (ior_output_file
,
76 ACE_Thread_Manager::instance ());
78 if (server_task
.activate (THR_JOINABLE
, 1, 1) == -1)
80 ACE_ERROR ((LM_ERROR
, "Error activating the server task."));
84 // Wait for the server task to activate.
87 ACE_Argv_Type_Converter
main_args_c (argc
, argv
);
90 CORBA::ORB_init (main_args_c
.get_argc (),
91 main_args_c
.get_TCHAR_argv (),
95 Client_Task
client_task (ior_input_file
,
97 ACE_Thread_Manager::instance ());
99 if (client_task
.activate (THR_JOINABLE
, 1, 1) == -1)
101 ACE_ERROR ((LM_ERROR
, "Error activating client thread.\n"));
105 ACE_Thread_Manager::instance ()->wait ();
110 catch (const CORBA::Exception
&)
115 ACE_DEBUG ((LM_DEBUG
, "Threaded client ready.\n"));