Changeset 5424 for source/ariba
- Timestamp:
- Jul 29, 2009, 3:30:42 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
source/ariba/utility/transport/rfcomm/rfcomm.cpp
r5423 r5424 33 33 public: 34 34 link_info(io_service& io ) : 35 up(false), local(), remote(), socket(io), connect_retries(0),35 io(io), up(false), local(), remote(), socket(new bluetooth::rfcomm::socket(io)), connect_retries(0), 36 36 size(0), buffer(NULL), sending(false) { 37 37 } 38 39 ~link_info() { 40 delete socket; 41 } 42 43 void reinit() { 44 delete socket; 45 socket = new bluetooth::rfcomm::socket(io); 46 up = false; 47 } 48 49 io_service& io; 38 50 39 51 // state 40 52 bool up; 41 53 rfcomm_endpoint local, remote; 42 bluetooth::rfcomm::socket socket;54 bluetooth::rfcomm::socket* socket; 43 55 int connect_retries; 44 56 … … 57 69 if (info != NULL && info->up) { 58 70 info->up = false; 59 info->socket .shutdown( bluetooth::rfcomm::socket::shutdown_both );71 info->socket->shutdown( bluetooth::rfcomm::socket::shutdown_both ); 60 72 } 61 73 } … … 124 136 125 137 // not found, or not up? ->try to (re-)connect 126 if (info==NULL || !info->up || info->socket .is_open() ) {138 if (info==NULL || !info->up || info->socket->is_open() ) { 127 139 logging_debug( "Connecting to " << endpoint.to_string() ); 128 if (info != NULL && (!info->up || !info->socket .is_open())) {140 if (info != NULL && (!info->up || !info->socket->is_open())) { 129 141 logging_debug("Old link is down. Trying to re-establish link."); 142 info->reinit(); 130 143 } else { 131 144 info = new link_info(io); … … 133 146 info->connect_retries = 0; 134 147 info->remote = endpoint; 135 info->socket .async_connect( convert(endpoint), boost::bind(148 info->socket->async_connect( convert(endpoint), boost::bind( 136 149 &rfcomm::handle_connect, this, 137 150 boost::asio::placeholders::error, info … … 192 205 // start accepting a connection 193 206 link_info* info = new link_info(io); 194 acceptor->async_accept( info->socket, boost::bind(207 acceptor->async_accept(*info->socket, boost::bind( 195 208 // bind parameters 196 209 &rfcomm::handle_accept, this, … … 221 234 // convert endpoints 222 235 info->up = true; 223 info->local = convert( info->socket .local_endpoint() );224 info->remote = convert( info->socket .remote_endpoint() );236 info->local = convert( info->socket->local_endpoint() ); 237 info->remote = convert( info->socket->remote_endpoint() ); 225 238 226 239 logging_debug("Accepted incoming connection from " … … 249 262 // increase counter 250 263 info->connect_retries++; 264 info->reinit(); 251 265 252 266 // retry connection attempt 253 info->socket .async_connect( convert(info->remote), boost::bind(267 info->socket->async_connect( convert(info->remote), boost::bind( 254 268 &rfcomm::handle_connect, this, 255 269 boost::asio::placeholders::error, info … … 263 277 // convert endpoints 264 278 info->up = true; 265 info->local = convert( info->socket .local_endpoint() );266 info->remote = convert( info->socket .remote_endpoint() );279 info->local = convert( info->socket->local_endpoint() ); 280 info->remote = convert( info->socket->remote_endpoint() ); 267 281 268 282 logging_debug( "Connected to " << info->remote.to_string() ); … … 280 294 void rfcomm::start_read(link_info* info) { 281 295 // start read 282 boost::asio::async_read( info->socket,296 boost::asio::async_read(*info->socket, 283 297 284 298 // read size of packet … … 321 335 322 336 // start read 323 boost::asio::async_read( info->socket,337 boost::asio::async_read(*info->socket, 324 338 // read size of packet 325 339 boost::asio::buffer(info->buffer, info->size), … … 378 392 379 393 // start writing 380 boost::asio::async_write( info->socket,394 boost::asio::async_write(*info->socket, 381 395 // read size of packet 382 396 buffer,
Note:
See TracChangeset
for help on using the changeset viewer.