当前位置: 首页>>代码示例>>C++>>正文


C++ EndPoint::port方法代码示例

本文整理汇总了C++中EndPoint::port方法的典型用法代码示例。如果您正苦于以下问题:C++ EndPoint::port方法的具体用法?C++ EndPoint::port怎么用?C++ EndPoint::port使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EndPoint的用法示例。


在下文中一共展示了EndPoint::port方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();

}
开发者ID:ossapp,项目名称:oss_core,代码行数:26,代码来源:SIPWebSocketConnection.cpp

示例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();
}
开发者ID:ossapp,项目名称:oss_core,代码行数:24,代码来源:SIPWebSocketConnection.cpp

示例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);
    }
}
开发者ID:ossapp,项目名称:oss_core,代码行数:98,代码来源:SIPWebSocketConnection.cpp

示例4: memcpy

EndPoint::EndPoint(const EndPoint& ep) {
  _port = ep.port();
  memcpy(&_addr._ip6, &ep.addr6(), sizeof(in6_addr));
}
开发者ID:dxiehz,项目名称:skyline,代码行数:4,代码来源:EndPoint.cpp


注:本文中的EndPoint::port方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。