本文整理汇总了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;
}
示例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);
}
}
}