本文整理汇总了C++中BNetworkAddress::HostName方法的典型用法代码示例。如果您正苦于以下问题:C++ BNetworkAddress::HostName方法的具体用法?C++ BNetworkAddress::HostName怎么用?C++ BNetworkAddress::HostName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BNetworkAddress
的用法示例。
在下文中一共展示了BNetworkAddress::HostName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _Setup
status_t
BProxySecureSocket::Connect(const BNetworkAddress& peer, bigtime_t timeout)
{
status_t status = InitCheck();
if (status != B_OK)
return status;
BSocket::Connect(fProxyAddress, timeout);
if (status != B_OK)
return status;
BString connectRequest;
connectRequest.SetToFormat("CONNECT %s:%d HTTP/1.0\r\n\r\n",
peer.HostName().String(), peer.Port());
BSocket::Write(connectRequest.String(), connectRequest.Length());
char buffer[256];
ssize_t length = BSocket::Read(buffer, sizeof(buffer) - 1);
if (length <= 0)
return length;
buffer[length] = '\0';
int httpStatus = 0;
int matches = scanf(buffer, "HTTP/1.0 %d %*[^\r\n]\r\n\r\n", httpStatus);
if (matches != 2)
return B_BAD_DATA;
if (httpStatus < 200 || httpStatus > 299)
return B_BAD_VALUE;
return _Setup();
}
示例2: _SetupConnect
status_t
BSecureSocket::Connect(const BNetworkAddress& peer, bigtime_t timeout)
{
status_t status = InitCheck();
if (status != B_OK)
return status;
status = BSocket::Connect(peer, timeout);
if (status != B_OK)
return status;
return _SetupConnect(peer.HostName().String());
}