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(); } }
void TcpConnecting::handleConnect(boost::shared_ptr<TcpSocket> socket, const boost::system::error_code &error, V4FirstIterator<tcp> endpoints) { boost::lock_guard<boost::recursive_mutex> guard(getCommonMutex()); if (abortRequested) { return; } if (!error) { enterConnectedState(); } else if (endpoints.hasNext()) { boost::system::error_code ec; if(startConnectionAttempt(socket, endpoints, ec)) { enterErrorState(ec.message()); return; } } else { enterErrorState(error.message()); return; } }