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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

C++ code doesn't execute past a certain point

Hi! I've been trying to make an UDP connection for receiving and sending data following Rama's tutorial; and I've managed to do it mostly, except for when it comes to closing connections.

I initialize listen socket like this:

 bool AUDPConnector::StartUDPReceiver(
     const FString& YourChosenSocketName,
     const FString& TheIP,
     const int32 ThePort
     FIPv4Address Addr;
     FIPv4Address::Parse(TheIP, Addr);
     //Create Socket
     FIPv4Endpoint Endpoint(Addr, ThePort);
     int32 BufferSize = 2 * 1024 * 1024;
     ListenSocket = FUdpSocketBuilder(*YourChosenSocketName).AsNonBlocking().AsReusable().BoundToEndpoint(Endpoint).WithReceiveBufferSize(BufferSize);
     FTimespan ThreadWaitTime = FTimespan::FromMilliseconds(100);
     UDPReceiver = new FUdpSocketReceiver(ListenSocket, ThreadWaitTime, TEXT("UDP RECEIVER"));
     UDPReceiver->OnDataReceived().BindUObject(this, &AUDPConnector::Recv);
     return true;

My code for closing the connection looks like this:

 void AUDPConnector::CloseConnections()
     if (UDPReceiver != nullptr)
         delete UDPReceiver;
         UDPReceiver = nullptr;
     if (ListenSocket)
     if (SenderSocket)

For some reason the code doesn't execute past delete UDPReceiver line, so sockets aren't closed and UDPReceiver isn't null and it causes unreal to hang when I "close" the connection. I've been stuck on this for couple of hours now and I'm totally lost on what to make of it. Halp?

Product Version: UE 4.18
more ▼

asked Aug 12 '18 at 03:54 PM in C++ Programming

avatar image

78 2 4 9

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

1 answer: sort voted first

I you're using breakpoints to see whether a line of code is being executed make sure you are running Debug configuration instead of development as with development configuration compiler optimizations may trick the debugger.

more ▼

answered Aug 13 '18 at 09:51 AM

avatar image

1k 8 24 26

(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