本文整理汇总了C++中Address::getService方法的典型用法代码示例。如果您正苦于以下问题:C++ Address::getService方法的具体用法?C++ Address::getService怎么用?C++ Address::getService使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Address
的用法示例。
在下文中一共展示了Address::getService方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sendProtocolHeader
void ASIOSocketWrapper::sendProtocolHeader(const MultiplexedSocketPtr&parentMultiSocket, const Address& address, const UUID&value, unsigned int numConnections) {
// if (paerntMultiSocket->isZeroDelim()) {
std::stringstream header;
header << "GET /" << value.toString() << " HTTP/1.1\r\n";
header << "Upgrade: WebSocket\r\n";
header << "Connection: Upgrade\r\n";
std::string hostname=address.getHostName();
for (std::string::iterator hi=hostname.begin(),he=hostname.end(); hi!=he; ++hi) {
*hi=std::tolower(*hi);
}
header << "Host: " << hostname;
if (address.getService()!="80")
header << ":" << address.getService();
header << "\r\n";
header << "Origin: " << address.getHostName() << "\r\n";
if (parentMultiSocket->getStreamType()!= TCPStream::RFC_6455) {
header << "Sec-WebSocket-Key1: x!|6 j9 U 1 guf 36Y04 | 4\r\n";
header << "Sec-WebSocket-Key2: 3 59 2 E4 _11 x80 \r\n";
} else {
header << "Sec-WebSocket-Version: 13\r\n";
header << "Sec-WebSocket-Key: MTIzNDU2Nzg5MGFiY2RlZg==\r\n";
}
header << "Sec-WebSocket-Protocol: "
<< (parentMultiSocket->getStreamType()==TCPStream::BASE64_ZERODELIM?"wssst":"sst")
<< numConnections << "\r\n";
header << "\r\n";
if (parentMultiSocket->getStreamType()!= TCPStream::RFC_6455) {
header << "abcdefgh";
}
std::string finalHeader(header.str());
Chunk * headerData= new Chunk(finalHeader.begin(),finalHeader.end());
rawSend(parentMultiSocket,headerData,true);
/*
}else {
UUID return_value=(parentMultiSocket->isZeroDelim()?massageUUID(UUID::random()):UUID::random());
Chunk *headerData=new Chunk(TCPStream::TcpSstHeaderSize);
copyHeader(&*headerData->begin(),parentMultiSocket->isZeroDelim()?TCPStream::WEBSOCKET_STRING_PREFIX():TCPStream::STRING_PREFIX(),value,numConnections);
rawSend(parentMultiSocket,headerData,true);
}
*/
}
示例2: connect
void ASIOConnectAndHandshake::connect(const ASIOConnectAndHandshakePtr &thus,
const Address&address,
bool no_delay){
tcp::resolver::query query(tcp::v4(), address.getHostName(), address.getService());
thus->mResolver.async_resolve(query,
boost::bind(&ASIOConnectAndHandshake::handleResolve,
thus,
no_delay,
boost::asio::placeholders::error,
boost::asio::placeholders::iterator));
}
示例3: connect
void ASIOConnectAndHandshake::connect(const ASIOConnectAndHandshakePtr &thus,
const std::tr1::shared_ptr<MultiplexedSocket>&connection,
const Address&address,
bool no_delay){
tcp::resolver::query query(tcp::v4(), address.getHostName(), address.getService(), Network::TCPResolver::query::all_matching);
thus->mResolver.async_resolve(
query,
connection->getStrand()->wrap(
boost::bind(&ASIOConnectAndHandshake::handleResolve,
thus,
connection,
address,
no_delay,
boost::asio::placeholders::error,
boost::asio::placeholders::iterator)
)
);
}
示例4: listen
bool TCPStreamListener::listen (const Address&address,
const Stream::SubstreamCallback&newStreamCallback) {
mTCPAcceptor = new TCPListener(*mIOService,tcp::endpoint(tcp::v4(), atoi(address.getService().c_str())));
return newAcceptPhase(mTCPAcceptor,mIOService,newStreamCallback);
}
示例5: listen
bool TCPStreamListener::listen (const Address&address,
const Stream::SubstreamCallback&newStreamCallback) {
close();
mData->acceptor = new TCPListener(mData->strand->service(),tcp::endpoint(tcp::v4(), atoi(address.getService().c_str())));
mData->cb = newStreamCallback;
mData->start(mData);
return true;
}