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"

TCP Server help needed

I want my UE4 application (on server) to send data via TCP to another computer (client). For now, let us have the client and server both be on localhost. IP: Port 15000

I do NOT want to use an actor or pawn or something else - I want this to be in a separate class that I can use in a way like: myDataSender.send(data);

Now, I have seen Ramas tutorial and tried many others. I can get the socket to connect on the server and the client appears to connect. However, no data appears to be sent - although, I am not exactly sure how to test that other than by having a breakpoint on my client to see when data arrives.

Here is what I am doing in my UE4 server application:


 class ImageDataSender
     FSocket* TCPSocket;
     bool Connect(FIPv4Address ipAddress, int port);
     bool Send(const uint8 * data, int32 dataSize, int32 bytesSent);
     bool IsConnected();


 bool ImageDataSender::Connect(FIPv4Address ipAddress, int port) {
     TSharedRef<FInternetAddr> address = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->CreateInternetAddr();
     TCPSocket = FTcpSocketBuilder("ImageSocket")
         //.Listening(8)//max number of connections allowed before refusing
     bool didConnect;
     if (TCPSocket) {
         UE_LOG(LogTemp, Warning, TEXT("Socket Created! Connecting to server..."));
         didConnect = TCPSocket->Connect(*address);
     else {
         UE_LOG(LogTemp, Warning, TEXT("Socket not created..."));
     if (didConnect) {
         UE_LOG(LogTemp, Warning, TEXT("Socket Connected!"));
     else {
         UE_LOG(LogTemp, Warning, TEXT("Failed to connect!!"));
 bool ImageDataSender::IsConnected() {
     if (TCPSocket == nullptr) {
     ESocketConnectionState connectionState = TCPSocket->GetConnectionState();
     if (connectionState == ESocketConnectionState::SCS_Connected) {
     else {
 bool ImageDataSender::Send(const uint8 * data, int32 dataSize, int32 bytesSent) {
     if (IsConnected()) {
         TCPSocket->Send(data, dataSize, bytesSent);

If I uncomment the line //.Listening(8), the didConnect == false. I feel that I should be using .Listening so that the server listens for incoming connection requests, but am not sure what I am doing wrong.

If someone could give me a sample of how to set this up, I'd really appreciate it.

Also, for what it is worth, my client is in c#.

Product Version: UE 4.10
more ▼

asked Dec 22 '15 at 09:30 AM in C++ Programming

avatar image

122 15 30 29

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

1 answer: sort voted first

I use a TCP server in one of my plugins and it works like a charm. Give it a try: https://github.com/moritz-wundke/UnrealRemote

more ▼

answered Dec 23 '15 at 06:53 PM

avatar image

6.4k 127 98 606

avatar image rich2020 Dec 23 '15 at 07:54 PM

Thank you. I've actually managed to figure this out using the FLiveEditorListenServer plugin available in UE4 source code.

avatar image Moss Dec 23 '15 at 10:26 PM

Nice! So if your issues are solved just accept the answer so others will benefit ftom it too ^^

(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