Hello there !
i got some trouble to make my udp socket working, as a local server -> client it works perfect but when i switch to my public IP i can’t receive anything,
I’m using the last 4.10 rev.
here is my socket:
FIPv4Address ip;
FIPv4Address::Parse(ips, ip);
addr.Add(ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->CreateInternetAddr());
addr[0]->SetIp(ip.GetValue());
addr[0]->SetPort(port);
client = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->CreateSocket(NAME_DGram, TEXT("MySuperUdpSocket"));
client->SetNonBlocking(true);
i’m using a list to store my TSharedRef or i can’t define it in the .H but this is not the problem.
my recv function look like this in the client:
uint32 PendingData;
client->HasPendingData(PendingData);
if (PendingData > 0)
{
NtlPAcket *pk = new NtlPAcket;
int32 BytesRead;
client->Recv((uint8*)pk, PendingData, BytesRead);
if (pk)
{
if (ThePC)
{
ThePC->parseMyPacket(pk);
}
}
}
So, is a way with UE4 and udp to make a socket to send and one to recv ? yes there is but i can’t figure it out:
receiver = FUdpSocketBuilder(TEXT("RECVER"))
.AsNonBlocking()
.AsReusable()
.BoundToAddress(ip);
.BoundToPort(7777)
.Build();
return receiver->Listen(50);
uint32 PendingData;
receiver->HasPendingData(PendingData);
if (PendingData > 0)
{
NtlPAcket *pk = new NtlPAcket;
int32 BytesRead;
receiver->Recv((uint8*)pk, PendingData, BytesRead);
if (pk)
{
if (ThePC)
{
ThePC->parseMyPacket(pk);
}
}
}
If anyone have a solution to let me use a udp socket receiver with a public IP !!
Thank you :).