Optimized Request and Response classes.

This commit is contained in:
2025-06-01 22:16:32 -07:00
parent 135f855309
commit 73f7ec1a8d
20 changed files with 877 additions and 231 deletions

View File

@@ -114,7 +114,7 @@ namespace ehs
hdl = EHS_INVALID_SOCKET;
}
void TCP::Bind(const Str_8& address, UInt_16 port)
void TCP::Bind(Str_8 address, const UInt_16 &port)
{
if (!IsValid() || bound || connection)
return;
@@ -124,7 +124,7 @@ namespace ehs
else if (ip == IP::V4)
Bind_v4(address, port);
this->localAddr = address;
this->localAddr = (Str_8 &&)address;
this->localPort = port;
bound = true;
@@ -207,26 +207,26 @@ namespace ehs
return client;
}
void TCP::Connect(const Str_8& address, const UInt_16 port)
void TCP::Connect(Str_8 address, const UInt_16 &port)
{
if (connection || !IsValid() || listening)
return;
remoteHostName = address;
remoteHostName = (Str_8 &&)address;
remotePort = port;
if (ip == IP::V6)
{
if (IsIPv6Only())
remoteAddr = DNS::Resolve(IP::V6, address);
remoteAddr = DNS::Resolve(IP::V6, remoteHostName);
else
remoteAddr = DNS::Resolve(address);
remoteAddr = DNS::Resolve(remoteHostName);
Connect_v6(remoteAddr, port);
}
else if (ip == IP::V4)
{
remoteAddr = DNS::Resolve(IP::V4, address);
remoteAddr = DNS::Resolve(IP::V4, remoteHostName);
Connect_v4(remoteAddr, port);
}
@@ -408,7 +408,7 @@ namespace ehs
return hdl != EHS_INVALID_SOCKET;
}
void TCP::Bind_v6(const Str_8& address, UInt_16 port)
void TCP::Bind_v6(const Str_8& address, const UInt_16 &port) const
{
sockaddr_in6 result = {};
result.sin6_family = AF_INET6;
@@ -444,7 +444,7 @@ namespace ehs
}
}
void TCP::Bind_v4(const Str_8& address, UInt_16 port)
void TCP::Bind_v4(const Str_8& address, const UInt_16 &port) const
{
sockaddr_in result = {};
result.sin_family = AF_INET;
@@ -479,7 +479,7 @@ namespace ehs
}
}
void TCP::Connect_v6(const Str_8& address, UInt_16 port)
void TCP::Connect_v6(const Str_8 &address, const UInt_16 &port)
{
sockaddr_in6 result = {};
result.sin6_family = AF_INET6;
@@ -516,7 +516,7 @@ namespace ehs
}
}
void TCP::Connect_v4(const Str_8& address, UInt_16 port)
void TCP::Connect_v4(const Str_8 &address, const UInt_16 &port)
{
sockaddr_in result = {};
result.sin_family = AF_INET;