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"

UDP Socket: FUdpSocketBuilder Errors

Hello,

I have a Python UDP socket server listening for packets from the game, but the game client socket is not being created.

The Output Log errors are:

 FUdpSocketBuilder: Failed to bind UpdSendSocket to 127.0.0.1:2345
 FUdpSocketBuilder: Failed to configure multicast for UpdSendSocket (loopback: 0, ttl: 1)
 FUdpSocketBuilder: Failed to create and initialize socket UpdSendSocket (last error: 0)

This is the code:

 #define PORT 2345
 
 FIPv4Endpoint EndPoint1(FIPv4Address(127, 0, 0, 1), PORT);
 
     FSocket *UdpSenderSocket = FUdpSocketBuilder(TEXT("UpdSendSocket"))
         .BoundToEndpoint(EndPoint1)
         .AsNonBlocking()
         .AsReusable()
         .WithBroadcast()
         .WithSendBufferSize(2 * 1024 * 1024);


Any suggestions? Thanks!

Product Version: UE 4.20
Tags:
more ▼

asked Oct 26 '18 at 11:17 PM in C++ Programming

avatar image

Doctor_Kannon
216 4 4 11

avatar image Doctor_Kannon Oct 27 '18 at 12:55 AM

Adding these lines after FUdpSocketBuilder will crash the game:

 int32 SendSize = 2 * 1024 * 1024;
 UdpSenderSocket->SetSendBufferSize(SendSize, SendSize);

The MiniDump Exception reads: The thread tried to read from or write to a virtual address for which it does not have the appropriate access.

This same exception appears when a C++ WinSock with Select (a non-blocking socket) waits for dropped packets.

avatar image HuangMM May 07 '19 at 07:33 AM

Hey, did you try this function in iOS? I try this in windows computers and it works fine. But when I launch to Ipad, FUdpSocketBuilder created fail and UdpSenderSocket is NULL. Anyone know why?

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

I figured it out. The Endpoint of FUdpSocketBuilder is the Client (game) IP/Port. The SendTo Endpoint is the Server IP/Port.

The error was caused by the Client's socket endpoint being already in use by the Server.

Code:

 #define PORT_CLIENT 1234
 #define PORT_SERVER 8888
 
 TArray<int> AUE4_UDP_Socket_Test_Client::UE4_UDP_Socket_IO(FString Message)
 {
     FIPv4Endpoint EndPoint_Client (FIPv4Address(127, 0, 0, 1), PORT_CLIENT);
     FIPv4Endpoint EndPoint_Server(FIPv4Address(127, 0, 0, 1), PORT_SERVER);
     
     FSocket *UdpSenderSocket = FUdpSocketBuilder(TEXT("UpdSendSocket"))
         .BoundToEndpoint(EndPoint_Client)
         .AsNonBlocking()
         .AsReusable()
         .WithBroadcast()
         .WithSendBufferSize(2 * 1024 * 1024);
     
     if (UdpSenderSocket)
     {
         UE_LOG(UE4_UDP_Log, Display, TEXT("Send socket create succesful"));
 
         int32 BytesSent;
         FTimespan waitTime = FTimespan(10);
         TCHAR *serializedChar = Message.GetCharArray().GetData();
         int32 size = FCString::Strlen(serializedChar);
         int32 sent = 0;
 
         bool success = UdpSenderSocket->SendTo((uint8*)TCHAR_TO_UTF8(serializedChar), size, BytesSent, *EndPoint_Server.ToInternetAddr());
         if (success && BytesSent > 0) // Success
         {
             UE_LOG(UE4_UDP_Log, Display, TEXT("SendTo Successful."));
         }
         else
         {
             UE_LOG(UE4_UDP_Log, Display, TEXT("SendTo Failed"));
         }
     }
 }
more ▼

answered Oct 28 '18 at 02:36 AM

avatar image

Doctor_Kannon
216 4 4 11

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
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