本文整理汇总了C++中EndPoint::address方法的典型用法代码示例。如果您正苦于以下问题:C++ EndPoint::address方法的具体用法?C++ EndPoint::address怎么用?C++ EndPoint::address使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EndPoint
的用法示例。
在下文中一共展示了EndPoint::address方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getRemoteAddress
OSS::IPAddress SIPWebSocketConnection::getRemoteAddress() const
/// Returns the last read source address
{
if (_lastReadAddress.isValid())
return _lastReadAddress;
if (_pServerConnection)
{
boost::system::error_code ec;
EndPoint ep = _pServerConnection->get_raw_socket().remote_endpoint(ec);
if (!ec)
{
boost::asio::ip::address ip = ep.address();
_lastReadAddress = OSS::IPAddress(ip.to_string(), ep.port());
return _lastReadAddress;
}
else
{
OSS_LOG_WARNING("SIPWebSocketConnection::getRemoteAddress() Exception " << ec.message());
return _connectAddress;
}
}
return OSS::IPAddress();
}
示例2: getLocalAddress
OSS::IPAddress SIPWebSocketConnection::getLocalAddress() const
/// Returns the local address binding for this transport
{
if (_localAddress.isValid())
return _localAddress;
if (_pServerConnection)
{
boost::system::error_code ec;
EndPoint ep = _pServerConnection->get_raw_socket().local_endpoint(ec);
if (!ec)
{
boost::asio::ip::address ip = ep.address();
_localAddress = OSS::IPAddress(ip.to_string(), ep.port());
return _localAddress;
}
else
{
OSS_LOG_WARNING("SIPWebSocketConnection::getLocalAddress() Exception " << ec.message());
}
}
return OSS::IPAddress();
}
示例3: handleRead
void SIPWebSocketConnection::handleRead(const boost::system::error_code& e, std::size_t bytes_transferred, OSS_HANDLE userData)
/// Handle completion of a read operation.
{
if (e || bytes_transferred <=0)
{
OSS_LOG_DEBUG("SIPWebSocketConnection::handleRead Exception " << e.message());
if (++_readExceptionCount >= 5)
{
OSS_LOG_ERROR("SIPWebSocketConnection::handleRead has reached maximum exception count. Bailing out.");
boost::system::error_code ignored_ec;
_connectionManager.stop(shared_from_this());
}
}
OSS_LOG_DEBUG("SIPWebSocketConnection::handleRead STARTING new connection");
std::string* buffer = reinterpret_cast<std::string*>(userData);
//
// set the last read address
//
if (!_lastReadAddress.isValid())
{
boost::system::error_code ec;
EndPoint ep = _pServerConnection->get_raw_socket().remote_endpoint(ec);
if (!ec)
{
boost::asio::ip::address ip = ep.address();
_lastReadAddress = OSS::IPAddress(ip.to_string(), ep.port());
}
else
{
OSS_LOG_WARNING("SIPWebSocketConnection::handleRead() Exception " << ec.message());
}
}
//
// Reset the read exception count
//
_readExceptionCount = 0;
_bytesRead = bytes_transferred;
if (!_pRequest)
{
_pRequest = SIPMessage::Ptr(new SIPMessage());
}
boost::tribool result;
const char* begin = buffer->data();
const char* end = buffer->data() + bytes_transferred;
boost::tuple<boost::tribool, const char*> ret = _pRequest->consume(begin, end);
result = ret.get<0>();
const char* tail = ret.get<1>();
if (result)
{
//
// Message has been read in full
//
_pDispatch->onReceivedMessage(_pRequest->shared_from_this(), shared_from_this());
if (tail >= end)
{
//
// The end of the SIPMessage is reached so we can simply reset the
// request buffer and start the read operation all over again
//
_pRequest.reset();
//
// We are done
//
return;
}
else
{
//
// This should not happen as there is one full message per read.
// The tail is within the range of the end of the read buffer.
//
OSS_ASSERT(false);
}
}
else if (!result)
{
_pRequest.reset();
}
else
{
//
// This should not happen as there is one full message per read.
// Partial message?
//
OSS_ASSERT(false);
}
}