# How to receive UDP messages?

**URL:** <https://forums.unrealengine.com/t/how-to-receive-udp-messages/375195>\
**Category:** Multiplayer & Networking\
**Tags:** udp, Networking, sockets, socket, unreal-engine, java, question\
**Created:** [November 2, 2016, 3:10pm UTC](https://forums.unrealengine.com/t/how-to-receive-udp-messages/375195 "2016-11-02T15:10:21Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_abdc6399](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_abdc6399](https://forums.unrealengine.com/u/anonymous_user_abdc6399)\
**Post date:** [November 2, 2016, 3:10pm UTC](https://forums.unrealengine.com/t/how-to-receive-udp-messages/375195/1 "2016-11-02T15:10:21Z")

</div>

I want to use UDP to let Unreal receive message from Java, but the messages sent from Java are not received by Unreal.  
In the beginPlay method of the player:  
ScreenMsg(“RECEIVER INIT”);

```
int32 BufferSize = 2 * 1024 * 1024;

ListenSocket = FUdpSocketBuilder(TEXT("MySocket"))
	.AsNonBlocking()
	.AsReusable()
	.BoundToAddress(FIPv4Address::Any)
	.BoundToPort(1324)
	.WithReceiveBufferSize(BufferSize);

FTimespan ThreadWaitTime = FTimespan::FromMilliseconds(100);
UDPReceiver = new FUdpSocketReceiver(ListenSocket, ThreadWaitTime, TEXT("UDP RECEIVER"));
UDPReceiver->OnDataReceived().BindUObject(this, &AMyProject2Character::Recv);

```

The Recv method is very, very simple:

```
ScreenMsg("Receiving Data...");

```

But “Receiving Data…” is never printed on the screen. Anyone an idea?

P.S. Probably irrelevant for the question, but may come in handy for people Googling this topic, the Java code I use for sending messages is:

```
public static void main(String args[]) throws Exception {
        DatagramSocket clientSocket = new DatagramSocket();
        InetAddress IPAddress = InetAddress.getByName("127.0.0.1");
        byte[] sendData;
        String sentence = "foo";
        sendData = sentence.getBytes();
        DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length, IPAddress, 1324);
        while (true) {
            clientSocket.send(sendPacket);
            Thread.sleep(100);
        }
    }

```

---

<div class="post-metadata">

**Author:** ![NorlinGames](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/norlingames/32/495614_2.png) [@NorlinGames](https://forums.unrealengine.com/u/NorlinGames)\
**Post date:** [November 5, 2016, 1:43pm UTC](https://forums.unrealengine.com/t/how-to-receive-udp-messages/375195/2 "2016-11-05T13:43:15Z")

</div>

Is there any news about that? I’m looking for docs for those UE4 low-level networking, but can’t find anything…

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_abdc6399](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_abdc6399](https://forums.unrealengine.com/u/anonymous_user_abdc6399)\
**Post date:** [November 27, 2016, 1:20pm UTC](https://forums.unrealengine.com/t/how-to-receive-udp-messages/375195/3 "2016-11-27T13:20:01Z")

</div>

_bump_  
Still looking for a solution…

---

<div class="post-metadata">

**Author:** ![NorlinGames](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/norlingames/32/495614_2.png) [@NorlinGames](https://forums.unrealengine.com/u/NorlinGames)\
**Post date:** [November 27, 2016, 1:32pm UTC](https://forums.unrealengine.com/t/how-to-receive-udp-messages/375195/4 "2016-11-27T13:32:23Z")

</div>

Have you looked into this tutorial: [A new, community-hosted Unreal Engine Wiki - Announcements - Unreal Engine Forums](https://wiki.unrealengine.com/Third_Party_Socket_Server_Connection) ?

(I didn’t tried it by myself, but looks exactly about sockets messaging)

---

<div class="post-metadata">

**Author:** ![VirtualLobster](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@VirtualLobster](https://forums.unrealengine.com/u/VirtualLobster)\
**Post date:** [January 27, 2017, 1:12pm UTC](https://forums.unrealengine.com/t/how-to-receive-udp-messages/375195/5 "2017-01-27T13:12:47Z")

</div>

Hi, did you find a solution?

---

<div class="post-metadata">

**Author:** ![Anonymous\_239c606b99e3ffa3df2e702d5285bcb2](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Anonymous\_239c606b99e3ffa3df2e702d5285bcb2](https://forums.unrealengine.com/u/Anonymous_239c606b99e3ffa3df2e702d5285bcb2)\
**Post date:** [May 9, 2018, 2:16am UTC](https://forums.unrealengine.com/t/how-to-receive-udp-messages/375195/6 "2018-05-09T02:16:59Z")

</div>

add UDPReceiver-\>Start();

---

<div class="post-metadata">

**Author:** ![Anonymous\_239c606b99e3ffa3df2e702d5285bcb2](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Anonymous\_239c606b99e3ffa3df2e702d5285bcb2](https://forums.unrealengine.com/u/Anonymous_239c606b99e3ffa3df2e702d5285bcb2)\
**Post date:** [May 9, 2018, 2:17am UTC](https://forums.unrealengine.com/t/how-to-receive-udp-messages/375195/7 "2018-05-09T02:17:12Z")

</div>

add UDPReceiver-\>Start();
