//-------------------------------------------------------------------------------- bool TNetDeviceAcceptor::Open( unsigned short port, unsigned char numNetWork ) { bool res = false; std::string sLocalHost; TResolverSelf_IP_v4 resolver; if( resolver.Get( sLocalHost, numNetWork ) == false ) return false; try { const ip::address_v4 ipv4_address_Local = ip::address_v4::from_string( sLocalHost ); const ip::address addr_Local( ipv4_address_Local ); const ip::tcp::endpoint endpoint_Local( addr_Local, port ); mSocket.open( endpoint_Local.protocol() ); SetReUse(); OffNagl(); Set_HardClose(); mSocket.bind( endpoint_Local ); // listen mSocket.listen( eMaxCountListen ); mIP_Port.Set( ipv4_address_Local.to_ulong(), port ); res = true; } catch( std::exception& e ) { GetLogger( STR_NAME_NET_TRANSPORT )-> WriteF_time( "Open Acceptor (%d,%d) FAIL: %s.\n", port, numNetWork, e.what() ); } return res; }
TMasterLogic::TMasterLogic() { SetCycleTime(100); mMasterForm = NULL; // значения по-умолчанию для параметров командной строки std::string sLocalHost; TResolverSelf_IP_v4 resolver; resolver.Get(sLocalHost, 0); TInputCmdDevTool::TInput input; input.ip_dst = boost::asio::ip::address_v4::from_string(sLocalHost).to_ulong(); input.port_self = MASTER_PORT; input.port_dst = SUPER_SERVER_PORT; mInputCmd.SetDefParam(input); }