Added new DNS::Resolve static method and organized it per OS.
This commit is contained in:
@@ -347,6 +347,55 @@ namespace ehs
|
||||
return (bool)r;
|
||||
}
|
||||
|
||||
void TCP::SetIPv6Only(const bool value)
|
||||
{
|
||||
if (addrType != AddrType::IPV6)
|
||||
{
|
||||
EHS_LOG_INT(LogType::WARN, 0, "Cannot set IPv6 only mode while socket is not using IPv6.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!IsValid())
|
||||
{
|
||||
EHS_LOG_INT(LogType::WARN, 1, "Attempted to set IPv6 only mode while socket is not initialized.");
|
||||
return;
|
||||
}
|
||||
|
||||
const int result = (int)value;
|
||||
if (setsockopt(hdl, IPPROTO_IPV6, IPV6_V6ONLY, &result, sizeof(int)) == -1)
|
||||
{
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to set IPv6 only mode with error #" + Str_8::FromNum(errno) + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
EHS_LOG_SUCCESS();
|
||||
}
|
||||
|
||||
bool TCP::IsIPv6Only() const
|
||||
{
|
||||
if (addrType != AddrType::IPV6)
|
||||
return false;
|
||||
|
||||
if (!IsValid())
|
||||
{
|
||||
EHS_LOG_INT(LogType::WARN, 1, "Attempted to set IPv6 only mode while socket is not initialized.");
|
||||
return false;
|
||||
}
|
||||
|
||||
int result;
|
||||
socklen_t len = sizeof(int);
|
||||
|
||||
if (getsockopt(hdl, IPPROTO_IPV6, IPV6_V6ONLY, &result, &len) == -1)
|
||||
{
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to set IPv6 only mode with error #" + Str_8::FromNum(errno) + ".");
|
||||
return false;
|
||||
}
|
||||
|
||||
EHS_LOG_SUCCESS();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool TCP::IsValid() const
|
||||
{
|
||||
return hdl != EHS_INVALID_SOCKET;
|
||||
|
Reference in New Issue
Block a user