void async_udp::udp_listener::listen_handler_( buffer_type bt, const boost::system::error_code& error, const size_t bytes_received ) { if ( error ) { static const int NO_ENOUGHT_BUFFER = 234; if ( error.value() == NO_ENOUGHT_BUFFER ) { enlarge_buffer_( bt ); register_listen_( bt, bytes_received ); } return; } if ( bytes_received == bt->size() && (*bt)[ bytes_received - 1 ] != '\0' ) { enlarge_buffer_( bt ); register_listen_( bt, bytes_received ); } else { { boost::mutex::scoped_lock lock( protect_messages_ ); messages_.push_back( std::string( bt->c_str(), bytes_received ) ); } register_listen_(); } }
void multicast_communication::udp_listener::listen_handler_( buffer_type bt, const boost::system::error_code& error, const size_t bytes_received ) { if ( error ) { static const int NO_ENOUGHT_BUFFER = 234; if ( error.value() == NO_ENOUGHT_BUFFER ) { enlarge_buffer_( bt ); register_listen_( bt, bytes_received ); } return; } if ( bytes_received == bt->size() && (*bt)[ bytes_received - 1 ] != '\0' ) { enlarge_buffer_( bt ); register_listen_( bt, bytes_received ); } else { { boost::mutex::scoped_lock lock( protect_messages_ ); switch(data_type_) { case 'Q' : push_vector<messages::quote_message>(messages_quote, quote_parser.parse(std::string( bt->c_str(), bytes_received ))); break; case 'T' : push_vector<messages::trade_message>(messages_trade, trade_parser.parse(std::string( bt->c_str(), bytes_received ))); break; } } register_listen_(); } }