Getting data through UDP connection, no data received

In UdpMessageTransport.cpp you can see both unicast and multicast UDP sockets being created. In UdpSocketReceiver.h you can find a helper class that simplifies receiving data from a UDP socket on a separate worker thread.

Ok, thanks, gmpreussner!!! I understand that in UE4 you should feel engine mechanics and read sources to handle problems!!

Were you able to get it to work? What was the problem?

I don’t know… deadline soon. Tried TCP and it’s OK

I think developers should add more samples to documentation with headers and dependences. And fix “Third Party Server” in wiki. Sources… good… But examples better) For Indie developers. Professionals are good in sources-reading.

UDP sockets are a very rare use case right now, and the Networking module in particular is highly experimental (as stated in the module’s readme.txt). When the API stabilizes we will add the documentation. Network programming is not a trivial matter and requires quite a bit of experience, because there are a thousand things that can go wrong. Most of the time it is infrastructure related and doesn’t even have anything to do with the code.

I will be on vacation throughout the next week. If you have any more problems, please feel free to add more comments here and I will get back to you no later than Monday 14th. Otherwise you can mark the question as answered. Thanks!

Hi - i’m really interested in getting some kind of socket listener working in UDP - I’m totally newb at c++ though. Can you give me a bit more info about how you’ve made your listener work? If I set up new c++ class in visual studio do I just copy your first code post into the H file and the second code post into the cpp file? I’ve had this stuff working fine using python in the past but i’m just unable to understand how the c++ code works - how does the engine call it? how often is it called? how can I get the received data into a blueprint? If anyone’s got time to help me out here i’d really appreciate it.

Dan

whoops, i meant UE4, not UDP - it can be UDP ot TCP as far as i’m concerned

Sorry for the delay - I just got back from my West Coast trip and finally had some time to start looking into this. The good news is that UDP server sockets seem to work as expected, that is for the most part.

However, I did find a problem with shutting down sockets on Windows that are bound to ANY_ADDRESS (0.0.0.0). It is possible that 127.0.0.1 is affected as well, but haven’t tested it yet. It looks like child processes, such as adb.exe that keep running after the Editor has exited can prevent these sockets from being closed.

As a quick workaround, could you please try to bind the socket to your PC’s actual IP address and see if that works? I know that this is not a permanent solution - I just want to verify that the rest of your code works.

I have verified that the UDP sockets in both UdpMessageTransport and SlateRemoteServer work with the current code (although they work only once if bound to 0.0.0.0, unless any child processes are being killed in Task Manager).

I checked in a fix for dangling socket handles on Windows (GitHub Commit). With that change I no longer see sockets not being closed. Can you try whether it fixes your problem as well? Thanks!