#include <iostream>
#include <vector>
#include <string>
#include <ace/OS_main.h>
class a_main_t
:
{
public :
a_main_t(
const std::vector< std::string > & rest_of_argv )
:
base_type_t( env, notification_mbox ),
m_rest_of_argv( rest_of_argv )
{}
virtual ~a_main_t()
{}
virtual void
virtual void
virtual void
virtual void
private :
const std::vector< std::string > m_rest_of_argv;
};
void
a_main_t::so_handle_client_connected(
{
std::cout << "\na_main_t::so_handle_client_connected\n"
"local address: "
"remote address: "
for( size_t i = 0; i < m_rest_of_argv.size(); ++i )
{
out_trx->ostream().write(
m_rest_of_argv[ i ].data(),
m_rest_of_argv[ i ].size() );
char newlines [] = "\r\n\r\n";
out_trx->ostream().write( newlines, 4 );
}
out_trx->commit();
}
void
a_main_t::so_handle_client_failed(
{
std::cout << "\na_main_t::so_handle_client_failed\n"
"reason: "<< msg.
m_reason << std::endl;
so_environment().stop();
}
void
a_main_t::so_handle_client_disconnected(
{
std::cout << "\na_main_t::so_handle_client_disconnected\n"
}
void
a_main_t::so_handle_incoming_package(
{
const size_t stream_size = in_trx->stream_size();
if( stream_size > 0 )
{
std::cout << "\na_main_t::so_handle_incoming_package\n"
"available data size: " << stream_size << "\n"
"data:\n";
std::vector< char > data( stream_size );
in_trx->istream().read( &data[0], stream_size );
std::cout.write( &data[0], stream_size );
std::cout << std::endl;
}
in_trx->commit();
}
struct client_data_t
{
std::string m_server_addr;
std::vector< std::string > m_rest_of_argv;
void
{
"active_obj" ) );
connector_creator( env );
std::unique_ptr< a_client_transport_agent_t > ta(
new a_client_transport_agent_t(
env,
connector_creator.create( m_server_addr ) ) );
new a_main_t(
env,
ta->query_notificator_mbox(),
m_rest_of_argv ) );
coop->add_agent( client );
if( 0 != rc )
std::cerr << "reg coop ret_code = " << rc << "\n\n";
else
{
std::cout << "Type \"quit\" to quit." << std::endl;
std::string cmd;
do
{
std::cin >> cmd;
} while( cmd != "quit" );
}
}
};
int
main( int argc, char ** argv )
{
if( 2 <= argc )
{
client_data_t client_data;
client_data.m_server_addr = argv[ 1 ];
for( size_t i = 2; i < argc; ++i )
client_data.m_rest_of_argv.push_back( argv[ i ] );
client_data,
&client_data_t::init,
.add_named_dispatcher(
.add_layer(
std::unique_ptr< so_5_transport::reactor_layer_t >(
}
else
std::cerr << "sample.so_5_transport.raw_channel.tcp_cln <port>" << std::endl;
return 0;
}