Finished implementing, now for the testing phase.

This commit is contained in:
2025-01-26 21:43:17 -08:00
parent 7bc4b9977d
commit 981b40d3b1
47 changed files with 2070 additions and 1597 deletions

View File

@@ -30,8 +30,8 @@ namespace ehs
{
}
TCP::TCP(const AddrType addrType)
: BaseTCP(addrType), hdl(EHS_INVALID_SOCKET)
TCP::TCP(const IP IP)
: BaseTCP(IP), hdl(EHS_INVALID_SOCKET)
{
TCP::Initialize();
}
@@ -78,9 +78,9 @@ namespace ehs
if (IsValid())
return;
if (addrType == AddrType::IPV6)
if (ip == IP::V6)
hdl = socket(AF_INET6, SOCK_STREAM, IPPROTO_TCP);
else if (addrType == AddrType::IPV4)
else if (ip == IP::V4)
hdl = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
else
return;
@@ -119,9 +119,9 @@ namespace ehs
if (!IsValid() || bound || connection)
return;
if (addrType == AddrType::IPV6)
if (ip == IP::V6)
Bind_v6(address, port);
else if (addrType == AddrType::IPV4)
else if (ip == IP::V4)
Bind_v4(address, port);
this->localAddr = address;
@@ -155,7 +155,7 @@ namespace ehs
UInt_32 addrLen = sizeof(sockaddr_in6);
TCP* client = new TCP();
client->addrType = addrType;
client->ip = ip;
client->localAddr = localAddr;
client->localPort = localPort;
client->connection = true;
@@ -215,18 +215,18 @@ namespace ehs
remoteHostName = address;
remotePort = port;
if (addrType == AddrType::IPV6)
if (ip == IP::V6)
{
if (IsIPv6Only())
remoteAddr = DNS::Resolve(AddrType::IPV6, address);
remoteAddr = DNS::Resolve(IP::V6, address);
else
remoteAddr = DNS::Resolve(address);
Connect_v6(remoteAddr, port);
}
else if (addrType == AddrType::IPV4)
else if (ip == IP::V4)
{
remoteAddr = DNS::Resolve(AddrType::IPV4, address);
remoteAddr = DNS::Resolve(IP::V4, address);
Connect_v4(remoteAddr, port);
}
@@ -338,7 +338,7 @@ namespace ehs
void TCP::SetIPv6Only(const bool value)
{
if (addrType != AddrType::IPV6)
if (ip != IP::V6)
{
EHS_LOG_INT(LogType::WARN, 0, "Cannot set IPv6 only mode while socket is not using IPv6.");
return;
@@ -362,7 +362,7 @@ namespace ehs
bool TCP::IsIPv6Only() const
{
if (addrType != AddrType::IPV6)
if (ip != IP::V6)
return false;
if (!IsValid())