[*] Linux connect by hostname regression/first pass?

This commit is contained in:
Reece Wilson 2023-09-23 09:25:18 +01:00
parent c05fabc633
commit 345cf608b3
3 changed files with 22 additions and 41 deletions

View File

@ -84,6 +84,10 @@ namespace Aurora::IO::Net
if (this->bHasRemoteMany_ && this->connectMany_.ips.size())
{
this->remoteEndpoint_ = this->connectMany_.ips[0];
if (this->remoteEndpoint_.transportProtocol == ETransportProtocol::kEnumInvalid)
{
this->remoteEndpoint_.transportProtocol = this->connectMany_.protocol;
}
}
if (this->osHandle_ &&

View File

@ -82,11 +82,14 @@ namespace Aurora::IO::Net
if (this->bHasRemoteMany_ && this->connectMany_.ips.size())
{
this->remoteEndpoint_ = this->connectMany_.ips[0];
if (this->remoteEndpoint_.transportProtocol == ETransportProtocol::kEnumInvalid)
{
this->remoteEndpoint_.transportProtocol = this->connectMany_.protocol;
}
}
this->CloseSocket();
this->osHandle_ = ::socket(
IPToDomain(this->remoteEndpoint_),
TransportToPlatformType(this->remoteEndpoint_) | SOCK_CLOEXEC,
@ -127,54 +130,24 @@ namespace Aurora::IO::Net
}
}
void Socket::FinishConstructAsync()
{
if (!this->SendPreestablish())
if (this->resolveLater.size() || this->bResolving_)
{
SysPushErrorIO("Preestablish drop");
if (!this->TryStartResolve())
{
this->SendErrorNoStream(GetLastNetError());
return;
}
return;
}
this->osHandle_ = ::socket(
IPToDomain(this->remoteEndpoint_),
TransportToPlatformType(this->remoteEndpoint_) | SOCK_CLOEXEC,
0
);
bool bMakeCloseExec { !bool(SOCK_CLOEXEC) };
if (this->osHandle_ == -1)
{
this->osHandle_ = ::socket(
IPToDomain(this->remoteEndpoint_),
TransportToPlatformType(this->remoteEndpoint_),
0
);
bMakeCloseExec = true;
}
if (this->osHandle_ == -1)
{
this->SendErrorNoStream(GetLastNetError());
return;
}
if (bMakeCloseExec)
{
(void)this->MakeCloseonexec();
}
this->osHandleOwner_->InitFromPairMove((int)this->osHandle_, (int)this->osHandle_);
if (!this->PrepareConnectOperations())
{
this->bForceFailConstruct_ = true;
return;
}
RenewSocket();
}
bool Socket::PrepareConnectOperations()
{
return this->MakeNonblocking();

View File

@ -175,6 +175,10 @@ namespace Aurora::IO::Net
pThat->bResolving_ = false;
pThat->connectMany_.uPort = pThat->remoteEndpoint_.uPort;
pThat->connectMany_.ips.insert(pThat->connectMany_.ips.end(), ips->begin(), ips->end());
if (pThat->remoteEndpoint_.transportProtocol == ETransportProtocol::kEnumInvalid)
{
pThat->remoteEndpoint_.transportProtocol = this->connectMany_.protocol;
}
pThat->bHasRemoteMany_ = true;
pThat->RenewSocket();
pThat->ConnectNext();