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 I get my Socket to start listening?

Hi, from looking at Ramas tutorial Rama<3 I've attempted to implement a listen server (that will do light work in the b.ground).

     ReceiveBufferSize = 2 * 1024 * 1024;
 void UServer::StartListening(UWorld* World)
     const FString SocketName = FString(TEXT("Socket"));
     const FIPv4Endpoint EndPoint = FIPv4Endpoint(FIPv4Address::InternalLoopback, 12345);
     Socket = FTcpSocketBuilder(SocketName).AsReusable().Listening(8).BoundToEndpoint(EndPoint);
     int32 NewSize = 0;
     Socket->SetReceiveBufferSize(ReceiveBufferSize, NewSize);
     //GetOuter()->GetWorld()->GetTimerManager().SetTimer(listenHandle,this, &UServer::Listerner, 0.01, true);
     if (World)
     World->GetTimerManager().SetTimer(listenHandle,this, &UServer::Listerner, 2, true);
 void UServer::Listerner()
     if (!Socket) return;
     //Remote address
     TSharedRef<FInternetAddr> RemoteAddress = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->CreateInternetAddr();
     bool Pending;
     // handle incoming connections
     if (Socket->HasPendingConnection(Pending) && Pending)
         //Already have a Connection? destroy previous
         if (ConnectionSocket)
         //New Connection receive!
         ConnectionSocket = Socket->Accept(*RemoteAddress, TEXT("RamaTCP Received Socket Connection"));
         GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Red, "debug msg");
         if (ConnectionSocket != NULL)
             //Global cache of current Remote Address
             RemoteAddressForConnection = FIPv4Endpoint(RemoteAddress);
             //UE_LOG "Accepted Connection! WOOOHOOOO!!!";
             //can thread this too

Before executing the timer I tired using the Listen method which did nothing.

In my test C# client program I attempt to connect, but no connection is made.

             TcpClient c = new TcpClient();
             c.Connect(IPAddress.Loopback, 12345);

Am I missing something, surely Socket->Accept() is a blocking method, that stops the flow of code, untill a client connects, right?

I made sure to open ports 12345 in my fire wall as well.

Does anyone know why my dummby client cannot connect to the server?

Product Version: UE 4.12
more ▼

asked Jul 28 '16 at 09:20 PM in C++ Programming

avatar image

219 19 17 24

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

1 answer: sort voted first

I couldn't find the answer to get my TCP listener to work in the engine.

It would work in the C# server, but not the UE4 server.

The project required me to send some data to a server that acts as a high scores board. For this, it would be quite silly to have the client connect, so instead I made the "server" a UDP listener that listens for UDP packets.

This enabled my UE4 client to send information to the UE4 UDP Server.

Props to Ramas UDP tutorial.

more ▼

answered Aug 16 '16 at 10:24 PM

avatar image

219 19 17 24

(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