I am currently trying to set up an UDP-Listener for my little Project i am working on…
I have a micro-controller which broadcast udp messages with a fixed ip and port.
Now i want to read these messages and print them as OnScreenDebugMessages.
Thank you very much, I think i slowly get a hang of how things actually compile with UE4… I never laid hands on such a big project with code-generation before…
Networking also has to be included for the FIPv4Address…
By this, I mean that how can we create a class that creates the socket, how can we create the function to receive the data, and how can we access that in the blueprints?
Sure no problem but first some question to know how detailed i should explain it… For my thesis i’m currently writing a BlueprintClass which receives CAN-Frames(Automotive Networking Protocol) packed into UDPs over Wireless Lan…
Do you know how to use the unreal header tool to expose custom c++ classes to Blueprint? (by that i mean the whole UCLASS UFUNCTION U PROPERTY stuff including events)
How to use Multithreading?
How to use shared-pointer and shared-ref for garbage collection?
let me know and i will write you a little tutorial on what i did
I know how to expose c++ classes to blueprints. I know multithreading and shared pointers for c++ in general. What I am trying to do is to create a client that can receive the broadcast messages from another software, over the UDP protocol.
Other than this, it would be awesome if you could tell me a way to create a server that can broadcast messages over UDP protocol.
Hello Overlawled,
Could you specify on the receiving functions, especially the "HasPendingData " one since it takes a “PendingDataSize” which I have no idea how to Get this variable. Could you also explain briefly how the receiver works? (since it might listen constantly to the server right?) do we use a loop or while(1) for that? Thank you very very much for your tutorial it helps tremendously!!!
PendingDataSize is a uint32 that gets passed into HasPendingData. HasPendingData then sets PendingDataSize to the value of the PendingData that the socket has waiting to be received.
To answer your second question you are indeed correct that it happens in a loop but more specifically in a Tick or TickComponent. In my case I’ve made a component that can be added to any AActor and inside the TickComponent of the class I check whether the socket has pending data or not.
uint32 PendingData;
Socket->HasPendingData(PendingData);
if (PendingData > 0)
{
uint8 *Recv = new uint8[PendingData];
int32 BytesRead;
Socket->Recv(Recv, PendingData, BytesRead);
//Do something with the received data
}
Hope this clears it up. I’ll have to do a part 2 of the tutorial.