4 #include "ace/Get_Opt.h"
6 static FILE *output_file
= 0;
7 // File into which the received data is written.
9 static const ACE_TCHAR
*output_file_name
= ACE_TEXT ("output");
10 // File handle of the file into which data is written.
16 FTP_Server_StreamEndPoint::get_callback (const char *,
17 TAO_AV_Callback
*&callback
)
19 // Return the server application callback to the AVStreams for further upcalls,
20 callback
= &this->callback_
;
25 FTP_Server_Callback::receive_frame (ACE_Message_Block
*frame
,
29 // Upcall from the AVStreams when there is data to be received from the
33 "FTP_Server_Callback::receive_frame\n"));
37 // Write the received data to the file.
38 size_t result
= ACE_OS::fwrite (frame
->rd_ptr (),
43 if (result
== frame
->length ())
44 ACE_ERROR_RETURN ((LM_ERROR
,
45 "FTP_Server_Flow_Handler::fwrite failed\n"),
48 frame
= frame
->cont ();
54 FTP_Server_Callback::handle_destroy ()
56 // Called when the ftp client requests the stream to be shutdown.
58 "FTP_Server_Callback::end_stream\n"));
70 delete this->mmdevice_
;
78 this->reactive_strategy_
.init (TAO_AV_CORE::instance ()->orb (),
79 TAO_AV_CORE::instance ()->poa ());
83 // Register the server mmdevice object with the ORB
84 ACE_NEW_RETURN (this->mmdevice_
,
85 TAO_MMDevice (&this->reactive_strategy_
),
88 // Register the mmdevice with the naming service.
89 CosNaming::Name
server_mmdevice_name (1);
90 server_mmdevice_name
.length (1);
91 server_mmdevice_name
[0].id
= CORBA::string_dup ("Server_MMDevice");
93 CORBA::Object_var mmdevice
=
94 this->mmdevice_
->_this ();
96 // Initialize the naming services
97 if (this->my_naming_client_
.init (TAO_AV_CORE::instance ()->orb ()) != 0)
98 ACE_ERROR_RETURN ((LM_ERROR
,
99 "Unable to initialize "
100 "the TAO_Naming_Client\n"),
103 // Register the server object with the naming server.
104 this->my_naming_client_
->rebind (server_mmdevice_name
,
111 parse_args (int argc
,
114 ACE_Get_Opt
opts (argc
,
119 while ((c
= opts ()) != -1)
124 output_file_name
= opts
.opt_arg ();
127 ACE_ERROR_RETURN ((LM_ERROR
,
128 "Usage: server -f filename"),
137 ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
141 // Initialize the ORB first.
142 CORBA::ORB_var orb
= CORBA::ORB_init (argc
,
152 // Make sure we have a valid <output_file>
153 output_file
= ACE_OS::fopen (output_file_name
,
155 if (output_file
== 0)
156 ACE_ERROR_RETURN ((LM_DEBUG
,
157 "Cannot open output file %s\n",
161 else ACE_DEBUG ((LM_DEBUG
,
162 "File Opened Successfully\n"));
164 CORBA::Object_var obj
165 = orb
->resolve_initial_references ("RootPOA");
167 // Get the POA_var object from Object_var.
168 PortableServer::POA_var root_poa
=
169 PortableServer::POA::_narrow (obj
.in ());
171 PortableServer::POAManager_var mgr
172 = root_poa
->the_POAManager ();
176 // Initialize the AVStreams components.
177 TAO_AV_CORE::instance ()->init (orb
.in (),
190 if ( orb
->work_pending())
192 orb
->perform_work ();
198 catch (const CORBA::Exception
& ex
)
200 ex
._tao_print_exception ("server::init");
204 ACE_OS::fclose (output_file
);