I have read through absolutely everything I can find online and tried all of it but I still can’t get data out of a socket.
I have a c++ application I built that sends data out to 127.0.0.1 on a fixed port. I’ve used Windows Message Analyzer and I can see it coming up in the correct port but I can’t get UE4 to see any data in the socket. It’s driving me nuts, this was already a workaround for a problem I couldn’t fix.
I have everything included and set up properly, it all compiles and runs properly it just doesn’t work.
I have been using FSocket and HasPendingData always returns as false.
I have read so many conflicting instructions, I have my Socket being built in BeginPlay (it was originally in the constructor but I read that this is problematic) and have tried using UDPSocketReceiver as well with similar lack of connection.
Any basic examples would be really appreciated, this shouldn’t be that difficult but I don’t know where I’m going wrong.
current code:
.h
FSocket* ListenSocket;
FUdpSocketReceiver* mySocketReceiver;
.cpp
**in the constructor:**
ListenSocket = NULL;
**in BeginPlay:**
FString TheIP = "";
FString Name = "whogivesa";
const int32 ThePort = 4444;
FIPv4Address Addr;
FIPv4Address::Parse(TheIP, Addr);
//Create Socket
FIPv4Endpoint Endpoint(Addr, ThePort);
//BUFFER SIZE
int32 BufferSize = 2 * 1024 * 1024;
ListenSocket = FUdpSocketBuilder(*Name)
.AsNonBlocking()
.AsReusable()
.BoundToAddress(Addr)
.BoundToPort(ThePort)
.Build();
**in Tick:**
uint8* Data = 0;
int32 tempBytesCounter;
if (ListenSocket->Recv(Data, sizeof(Data), tempBytesCounter))
{
// do something
}