x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How to receive UDP messages?

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);
         }
     }

Product Version: UE 4.13
Tags:
more ▼

asked Nov 02 '16 at 03:10 PM in C++ Programming

avatar image

Volex
11 1 2 4

avatar image norlin Nov 05 '16 at 01:43 PM

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

avatar image Volex Nov 27 '16 at 01:20 PM

bump Still looking for a solution...

avatar image VirtualLobster Jan 27 '17 at 01:12 PM

Hi, did you find a solution?

(comments are locked)
10|2000 characters needed characters left

3 answers: sort voted first

Have you looked into this tutorial: https://wiki.unrealengine.com/Third_Party_Socket_Server_Connection ?

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

more ▼

answered Nov 27 '16 at 01:32 PM

avatar image

norlin
55 7 16 21

(comments are locked)
10|2000 characters needed characters left

add UDPReceiver->Start();

more ▼

answered May 09 '18 at 02:17 AM

avatar image

小趣
11 1 3

(comments are locked)
10|2000 characters needed characters left

add UDPReceiver->Start();

more ▼

answered May 09 '18 at 02:16 AM

avatar image

小趣
11 1 3

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question