Changeset 4910 for source/ariba/utility/bootstrap/modules/periodicbroadcast
- Timestamp:
- Jul 14, 2009, 4:34:14 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
source/ariba/utility/bootstrap/modules/periodicbroadcast/PeriodicBroadcast.h
r4896 r4910 116 116 class udp_server { 117 117 private: 118 udp::socket socket_v4; 119 udp::socket socket_v6; 118 udp::socket socket_v4_listen; 119 udp::socket socket_v4_send; 120 //udp::socket socket_v6; 120 121 udp::endpoint remote_endpoint_; 121 122 boost::array<char, 1500> recv_buffer_; … … 126 127 udp_server(boost::asio::io_service& io_service, ServiceList* _services, boost::mutex* _servicesmutex) 127 128 : services(_services), servicesmutex(_servicesmutex), 128 socket_v4 (io_service), socket_v6(io_service){129 socket_v4_listen(io_service), socket_v4_send(io_service) /*, socket_v6(io_service)*/ { 129 130 130 131 boost::asio::ip::udp::endpoint listen_endpoint_v4( 131 boost::asio::ip:: address_v4::broadcast(),132 boost::asio::ip::udp::v4() /*boost::asio::ip::address_v4::any()*/, 132 133 PeriodicBroadcast::serverport_v4); 133 134 135 /* 134 136 boost::asio::ip::udp::endpoint listen_endpoint_v6( 135 137 boost::asio::ip::address_v6::from_string("ff02::1"), 136 138 PeriodicBroadcast::serverport_v6); 139 */ 137 140 138 141 boost::system::error_code err; 139 142 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"); 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"); 160 164 161 165 //socket_v6.bind( listen_endpoint_v6 ); … … 178 182 udp::endpoint endp(udp::v4(), PeriodicBroadcast::serverport_v4); 179 183 endp.address( boost::asio::ip::address_v4::broadcast() ); 180 socket_v4 .send_to( boost::asio::buffer(pnt, len), endp, 0, err );184 socket_v4_send.send_to( boost::asio::buffer(pnt, len), endp, 0, err ); 181 185 if(err) logging_warn("failed sending message through ipv4 socket"); 182 186 } … … 190 194 private: 191 195 void start_receive(){ 192 socket_v4 .async_receive_from(196 socket_v4_listen.async_receive_from( 193 197 boost::asio::buffer(recv_buffer_), remote_endpoint_, 194 198 boost::bind(&udp_server::handle_receive, this, 195 199 boost::asio::placeholders::error, 196 200 boost::asio::placeholders::bytes_transferred)); 197 201 /* 198 202 socket_v6.async_receive_from( 199 203 boost::asio::buffer(recv_buffer_), remote_endpoint_, … … 201 205 boost::asio::placeholders::error, 202 206 boost::asio::placeholders::bytes_transferred)); 207 */ 203 208 } 204 209 … … 248 253 249 254 udp_server server; 250 251 255 }; 252 256
Note:
See TracChangeset
for help on using the changeset viewer.