本文整理汇总了C++中boost::asio::ip::udp::socket::is_open方法的典型用法代码示例。如果您正苦于以下问题:C++ socket::is_open方法的具体用法?C++ socket::is_open怎么用?C++ socket::is_open使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::asio::ip::udp::socket
的用法示例。
在下文中一共展示了socket::is_open方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createSingleSocket
bool STUNClient::createSingleSocket(
const std::string& stunServer,
boost::asio::ip::udp::socket& socket,
const OSS::IPAddress& lAddr,
OSS::IPAddress& externalAddress)
{
OSS::mutex_critic_sec_lock globalLock(_csGlobal);
_test1Responded = false;
_test2Responded = false;
_test3Responded = false;
_test10Responded = false;
_test1ChangedAddr = OSS::IPAddress();
_test1MappedAddr = OSS::IPAddress();
_test10MappedAddr = OSS::IPAddress();
_sendCount = 0;
OSS::IPAddress localAddress = lAddr;
OSS::IPAddress targetAddress = OSS::IPAddress::fromV4IPPort(stunServer.c_str());
if (!targetAddress.isValid() || !localAddress.isValid())
return false;
if (!targetAddress.getPort())
targetAddress.setPort(STUN_PORT);
if (!socket.is_open())
{
socket.open(boost::asio::ip::udp::v4());
boost::asio::ip::udp::endpoint ep;
ep = boost::asio::ip::udp::endpoint(localAddress.address(), localAddress.getPort());
boost::system::error_code ec;
socket.bind(ep, ec);
if (ec)
return false;
}
while (_sendCount < 15)
{
_sendCount++;
if (!_test1Responded)
sendTestRequest(socket, targetAddress, 1);
else
break;
}
if (_test1Responded)
{
externalAddress = _test1MappedAddr;
return externalAddress.isValid();
}
return false;
}
示例2: IsConnected
gcc_pure
bool IsConnected() const {
const ScopeLock protect(mutex);
return socket.is_open();
}
示例3: IsDefined
bool IsDefined() const {
const ScopeLock protect(mutex);
return resolving || socket.is_open();
}
示例4:
inline bool
UdpChannel::isListening() const
{
return m_socket.is_open();
}
示例5: IsDefined
bool IsDefined() const {
return socket.is_open();
}