Changeset 4920 for source/ariba
- Timestamp:
- Jul 15, 2009, 7:42:25 AM (15 years ago)
- Location:
- source/ariba
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
source/ariba/overlay/OverlayBootstrap.cpp
r4919 r4920 62 62 63 63 manager.registerCallback( this ); 64 //manager.registerModule( BootstrapManager::BootstrapTypePeriodicBroadcast );64 manager.registerModule( BootstrapManager::BootstrapTypePeriodicBroadcast ); 65 65 } 66 66 void OverlayBootstrap::stop(){ … … 70 70 71 71 manager.unregisterCallback( this ); 72 //manager.unregisterModule( BootstrapManager::BootstrapTypePeriodicBroadcast );72 manager.unregisterModule( BootstrapManager::BootstrapTypePeriodicBroadcast ); 73 73 } 74 74 -
source/ariba/utility/bootstrap/modules/periodicbroadcast/PeriodicBroadcast.cpp
r4866 r4920 66 66 : BootstrapModule(_callback), 67 67 server(io_service, &newRemoteServices, &newRemoteServicesMutex) { 68 69 io_service.run(); 68 70 } 69 71 70 72 PeriodicBroadcast::~PeriodicBroadcast(){ 73 io_service.stop(); 71 74 } 72 75 -
source/ariba/utility/bootstrap/modules/periodicbroadcast/PeriodicBroadcast.h
r4910 r4920 116 116 class udp_server { 117 117 private: 118 udp::socket socket_v4_listen; 119 udp::socket socket_v4_send; 120 //udp::socket socket_v6; 118 udp::socket socket_v4; 119 udp::socket socket_v6; 121 120 udp::endpoint remote_endpoint_; 122 121 boost::array<char, 1500> recv_buffer_; … … 127 126 udp_server(boost::asio::io_service& io_service, ServiceList* _services, boost::mutex* _servicesmutex) 128 127 : services(_services), servicesmutex(_servicesmutex), 129 socket_v4 _listen(io_service), socket_v4_send(io_service) /*, socket_v6(io_service)*/{128 socket_v4(io_service), socket_v6(io_service) { 130 129 131 130 boost::asio::ip::udp::endpoint listen_endpoint_v4( 132 boost::asio::ip:: udp::v4() /*boost::asio::ip::address_v4::any()*/,131 boost::asio::ip::address_v4::any(), 133 132 PeriodicBroadcast::serverport_v4); 134 133 135 /*136 134 boost::asio::ip::udp::endpoint listen_endpoint_v6( 137 boost::asio::ip::address_v6:: from_string("ff02::1"),135 boost::asio::ip::address_v6::any(), 138 136 PeriodicBroadcast::serverport_v6); 139 */140 137 141 138 boost::system::error_code err; 142 139 143 //err = socket_v4.open( listen_endpoint_v4.protocol(), err );144 //if(err) logging_warn("failed opening ipv4 socket");145 146 //err = socket_v6.open( listen_endpoint_v6.protocol(), err );147 //if(err) logging_warn("failed opening ipv6 socket");148 149 //err = socket_v4.set_option( boost::asio::ip::udp::socket::reuse_address(true), err );150 //if(err) logging_warn("failed setting reuse address option on ipv4 socket");151 152 //err = socket_v6.set_option( boost::asio::ip::udp::socket::reuse_address(true), err );153 //if(err) logging_warn("failed setting reuse address option on ipv6 socket");154 155 err = socket_v4 _listen.set_option( boost::asio::socket_base::broadcast(true), err );156 err = socket_v4_send.set_option( boost::asio::socket_base::broadcast(true), err);157 //if(err) logging_warn("failed setting broadcast option on ipv4 socket"); 158 159 //err = socket_v6.set_option( boost::asio::socket_base::broadcast(true), err);160 //if(err) logging_warn("failed setting broadcast option on ipv6 socket"); 161 162 //err = socket_v4.bind( listen_endpoint_v4, err);163 //if(err) logging_warn("failed binding ipv4 socket"); 164 165 //socket_v6.bind( listen_endpoint_v6);140 err = socket_v4.open( listen_endpoint_v4.protocol(), err ); 141 if(err) logging_warn("failed opening ipv4 socket"); 142 143 err = socket_v6.open( listen_endpoint_v6.protocol(), err ); 144 if(err) logging_warn("failed opening ipv6 socket"); 145 146 err = socket_v4.set_option( boost::asio::ip::udp::socket::reuse_address(true), err ); 147 if(err) logging_warn("failed setting reuse address option on ipv4 socket"); 148 149 err = socket_v6.set_option( boost::asio::ip::udp::socket::reuse_address(true), err ); 150 if(err) logging_warn("failed setting reuse address option on ipv6 socket"); 151 152 err = socket_v4.set_option( boost::asio::socket_base::broadcast(true), err ); 153 if(err) logging_warn("failed setting broadcast option on ipv4 socket"); 154 155 err = socket_v6.set_option( boost::asio::socket_base::broadcast(true), err ); 156 if(err) logging_warn("failed setting broadcast option on ipv6 socket"); 157 158 err = socket_v4.bind( listen_endpoint_v4, err ); 159 if(err) logging_warn("failed binding ipv4 socket"); 160 161 err = socket_v6.bind( listen_endpoint_v6 ); 162 if(err) logging_warn("failed binding ipv6 socket"); 166 163 167 164 start_receive(); … … 182 179 udp::endpoint endp(udp::v4(), PeriodicBroadcast::serverport_v4); 183 180 endp.address( boost::asio::ip::address_v4::broadcast() ); 184 socket_v4 _send.send_to( boost::asio::buffer(pnt, len), endp, 0, err );181 socket_v4.send_to( boost::asio::buffer(pnt, len), endp, 0, err ); 185 182 if(err) logging_warn("failed sending message through ipv4 socket"); 186 183 } 187 { /*184 { 188 185 udp::endpoint endp(udp::v6(), PeriodicBroadcast::serverport_v6); 189 186 endp.address( boost::asio::ip::address_v6::from_string("ff02::1") ); 190 187 socket_v6.send_to( boost::asio::buffer(pnt, len), endp, 0, ignored_error ); 191 */}188 } 192 189 } 193 190 194 191 private: 195 192 void start_receive(){ 196 socket_v4 _listen.async_receive_from(193 socket_v4.async_receive_from( 197 194 boost::asio::buffer(recv_buffer_), remote_endpoint_, 198 195 boost::bind(&udp_server::handle_receive, this, 199 196 boost::asio::placeholders::error, 200 197 boost::asio::placeholders::bytes_transferred)); 201 /* 198 202 199 socket_v6.async_receive_from( 203 200 boost::asio::buffer(recv_buffer_), remote_endpoint_, … … 205 202 boost::asio::placeholders::error, 206 203 boost::asio::placeholders::bytes_transferred)); 207 */208 204 } 209 205 … … 244 240 const boost::system::error_code& error, 245 241 std::size_t /*bytes_transferred*/){ 246 242 247 243 if(error) 248 244 logging_warn("failed sending out message"); 249 245 250 246 } 251 247 … … 253 249 254 250 udp_server server; 251 255 252 }; 256 253
Note:
See TracChangeset
for help on using the changeset viewer.