std::string _getZmqURI( const std::string& instance ) { const size_t pos = instance.find( ":" ); const std::string& host = instance.substr( 0, pos ); const std::string& port = instance.substr( pos + 1 ); return buildZmqURI( host, boost::lexical_cast< uint16_t >( port )); }
Publisher( const servus::URI& uri_, const uint32_t announceMode ) : Sender( uri_, 0, ZMQ_PUB ) , _service( std::string( "_" ) + uri.getScheme() + "._tcp" ) { const std::string& zmqURI = buildZmqURI( uri ); if( zmq_bind( socket, zmqURI.c_str( )) == -1 ) { zmq_close( socket ); socket = 0; ZEQTHROW( std::runtime_error( std::string( "Cannot bind publisher socket '" ) + zmqURI + "': " + zmq_strerror( zmq_errno( )))); } _initService( announceMode ); }
Impl( const URI& uri_, const std::string& session ) : detail::Sender( uri_, 0, ZMQ_PUB ) , _service( PUBLISHER_SERVICE ) , _session( session == DEFAULT_SESSION ? getDefaultSession() : session ) { if( session.empty( )) ZEROEQTHROW( std::runtime_error( "Empty session is not allowed for publisher" )); const std::string& zmqURI = buildZmqURI( uri ); if( zmq_bind( socket, zmqURI.c_str( )) == -1 ) { zmq_close( socket ); socket = 0; ZEROEQTHROW( std::runtime_error( std::string( "Cannot bind publisher socket '" ) + zmqURI + "': " + zmq_strerror( zmq_errno( )))); } initURI(); if( session != NULL_SESSION ) _initService(); }