void UdpSocket::handleSend(const boost::system::error_code &err, std::shared_ptr<Buffer> buffer, V4FirstIterator<udp> endpoints) { boost::lock_guard<boost::recursive_mutex> guard(commonMutex_); if(err && endpoints.hasNext()) { udp::endpoint endpoint; udp::socket *sock; do { endpoint = endpoints.next(); sock = getAppropriateSocket(endpoint); } while(!sock->is_open() && endpoints.hasNext()); if(sock->is_open()) { sock->async_send_to( boost::asio::const_buffers_1(buffer->getData(), buffer->size()), endpoint, boost::bind(&UdpSocket::handleSend, shared_from_this(), boost::asio::placeholders::error, buffer, endpoints)); return; } } asyncSendInProgress_ = false; if (!sendqueue_.isEmpty()) { asyncSend(); } }
boost::system::error_code TcpConnecting::startConnectionAttempt(boost::shared_ptr<TcpSocket> socket, V4FirstIterator<tcp> endpoints, boost::system::error_code &ec) { if (getSocket().close(ec)) { return ec; } tcp::endpoint endpoint = endpoints.next(); getSocket().async_connect(endpoint, boost::bind( &TcpConnecting::handleConnect, this, socket, boost::asio::placeholders::error, endpoints)); return ec; }