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


C++ shared_ptr::numSockets方法代码示例

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


在下文中一共展示了shared_ptr::numSockets方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: checkHeaderContents

    void ASIOConnectAndHandshake::checkHeaderContents(const std::tr1::shared_ptr<MultiplexedSocket>&connection,
						      bool noDelay,
                                                  unsigned int whichSocket,
                                                  Array<uint8,TCPStream::MaxWebSocketHeaderSize>* buffer,
                                                  const ErrorCode&error,
                                                  std::size_t bytes_received) {
    if (connection) {
        char normalMode[]="HTTP/1.1 101 Web Socket Protocol Handshake\r\n";

        size_t whereHeaderEnds=3;
        for (;whereHeaderEnds+1<bytes_received;++whereHeaderEnds) {
            if ((*buffer)[whereHeaderEnds]=='\n'&&
                (*buffer)[whereHeaderEnds-1]=='\r'&&
                (*buffer)[whereHeaderEnds-2]=='\n'&&
                (*buffer)[whereHeaderEnds-3]=='\r') {
                break;
            }
        }
        if (!memcmp(buffer->begin(),normalMode,sizeof(normalMode)-1/*not including null*/)) {
            if (mFinishedCheckCount==(int)connection->numSockets()) {
                mFirstReceivedHeader=*buffer;
            }
            if (mFinishedCheckCount>=1) {
                boost::asio::ip::tcp::no_delay option(noDelay);
                connection->getASIOSocketWrapper(whichSocket).getSocket().set_option(option);
                mFinishedCheckCount--;
                if (mFinishedCheckCount==0) {
                    connection->connectedCallback();
                }
                if (connection->getStreamType()==Sirikata::Network::TCPStream::RFC_6455) {
                    ptrdiff_t diff = whereHeaderEnds+1;
                    MemoryReference mb(buffer->begin()+diff,bytes_received-diff);
                    MakeASIOReadBuffer(connection,whichSocket,mb, connection->getStreamType());
                }else {
                    // Note we shift an additional 16 bytes, ignoring the required
                    // WebSocket md5 response
                    ptrdiff_t diff = whereHeaderEnds+1+16;
                    if ((ptrdiff_t)bytes_received<diff) {
                        diff = bytes_received;
                    }
                    MemoryReference mb(buffer->begin()+diff,bytes_received-diff);
                    MakeASIOReadBuffer(connection,whichSocket,mb, connection->getStreamType());
                }
            }else {
                mFinishedCheckCount-=1;
            }
        }else {
                connection->connectionFailedCallback(whichSocket,"Bad header comparison "
                                                     +std::string((char*)buffer->begin(),bytes_received)
                                                     +" does not match "
                                                     +std::string(normalMode));
                mFinishedCheckCount-=connection->numSockets();
                mFinishedCheckCount-=1;
        }
    }
    delete buffer;
}
开发者ID:AsherBond,项目名称:sirikata,代码行数:57,代码来源:ASIOConnectAndHandshake.cpp

示例2: handleResolve

void ASIOConnectAndHandshake::handleResolve(const ASIOConnectAndHandshakePtr& thus,
					    const std::tr1::shared_ptr<MultiplexedSocket>&connection,
                                            const Address&address,
                                            bool no_delay,
                                            const boost::system::error_code &error,
                                            tcp::resolver::iterator it) {
    if (!connection) {
        return;
    }
    if (error) {
        connection->connectionFailedCallback(error);
    }else {
        unsigned int numSockets=connection->numSockets();
        for (unsigned int whichSocket=0;whichSocket<numSockets;++whichSocket) {
            connectToIPAddress(thus,
			       connection,
                               address,
                               no_delay,
                               whichSocket,
                               it,
                               boost::asio::error::host_not_found);
        }
    }

}
开发者ID:AsherBond,项目名称:sirikata,代码行数:25,代码来源:ASIOConnectAndHandshake.cpp


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