Hi, im going crazy over here…
I successfully created udp sockets before but now it always results in the socket error 21 “Address is not available” or as ESocketError SE_EADDRNOTAVAIL…
I tried it on different PCs with version 4.1 and 4.2…
set the Socket as reusable and not…
created everything by hand and tried the UdpSocketBuilder…
it ALWAYS resulted in this error…
I even wrote a little console application in C# to verify that my PC’s Socket API works… it does
when i debugged, i saw that my address and port order are reversed so i tried different ip adresses as A.B.C.D and D.C.B.A
Here is my code:
void AUdpActor::createSocket()
{
ISocketSubsystem* theSocketSubsystem;
theSocketSubsystem = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM);
ESocketErrors err;
TSharedPtr<FSocket, ESPMode::NotThreadSafe> Socket;
TSharedPtr<FInternetAddr, ESPMode::NotThreadSafe> addr;
addr = theSocketSubsystem->CreateInternetAddr();
addr->SetPort(21338);
bool bIsValid;
addr->SetIp(TEXT("192.168.2.222"), bIsValid);
Socket = MakeShareable(theSocketSubsystem->CreateSocket(NAME_DGram, TEXT("testSocket"), true));
Socket->SetReuseAddr(true);
Socket->Bind(*addr);
err = theSocketSubsystem->GetLastErrorCode();
// second try with the Socket Builder
FSocket* Socket = FUdpSocketBuilder(TEXT("SomeSocket")).BoundToAddress(FIPv4Address(192, 168, 2, 222)).BoundToPort(23123).AsReusable().Build();
}
I am glad for every suggestion someone might have…