Rama TCP Example

Has anyone got a working port of Rama’s tcp example? Trying to use it as a base thanks for any info!

There are plenty C++ networking libraries out there. Just choose one that suits your needs and link it to UE. (
GitHub - cesanta/mongoose: Embedded Web Server
GitHub - Cylix/tacopie: C++ TCP Library - NO LONGER MAINTAINED
GitHub - Qihoo360/evpp: A modern C++ network library for developing high performance network services in TCP/UDP/HTTP protocols.

If you just need a low level TCP socket, there is this:…ket/index.html

I am sorry @Mellnik but I am not so sure I understand your answer. @Rama has provided a TCP socket example FOR Unreal Engine. Most of the links you provided are just generic C++ socket libraries. Can you inform us how many of those have been verified to work in Unreal Engine 4.20? I too have spent a month to try and get a TCP Server working under (then 4.19) but I suspect the same problems exist in 4.20. Here is my thread to it. Need a TCP Listener that works on 4.19 - Unreal Engine Forums
Secondly, if we are not allowed to ask questions about code that other users shared, then what is the use of a forum? So your attitude towards this question is really uncalled for. Unreal Engine does not really have a support line we can use. This forum is, therefore, a lifeline for many. The general lack of coding examples for most of the Unreal C++ classes is a problem that many of us deal with on a daily basis. People like Rama makes this situation better by sharing his code, but sometimes his code gets stale as new releases of the product are released. Perhaps we should rather point to the real problem - lack of C++ coding examples except for the most basic tasks and that this community is trying their best to deal with that problem. One would think that something like a TCP/UDP server and client would be supplied sample code that is maintained by Epic, along with other working examples for functionality like multithreaded applications and other topics developers find to be complex. You are not making this forum better with your comments.

Here is how you do it:

  1. Choose a random C++ library and compile it to a .lib
  2. Add the lib and header files to your .Build.cs (PublicAdditionalLibraries, PublicIncludePaths)
  3. Include the header files in your games Visual Studio project.
  4. You can now use the libraries functions to create the code you need. For a TCP server you would probably go into your GameInstance and create a function like “CreateTCPServer(ip, port)”. Now read the libraries documentation and implement it accordingly.

That’s the beauty in UE4. You can do anything, you will just need to code a wrapper around the library for it to work in Blueprints etc.

Depending on what u try to achieve, i can share some code i wrote based on Rama’s example and some code i found in the engine, to have a very basic TCP connection that communicates with an external server, using basic UE4 sockets, receiver thread, game thread synchronization, …
I did not test the code in UE4.20 yet, but as it’s using raw sockets provided by the engine, i don’t expect much issues there.

@Mellnik have you actually done this? I would like to see a plugin project where you have taken a generic TCP library and compiled it so that the functions can be exposed as blueprint nodes. And why not use the libraries that Epic provides like FTCPServer? That is the real question here - has anybody got this working under 4.20?

@Fallonsnest do you have an example that creates a TCP Server in Unreal? That would be really helpful.

The library functions won’t get magically exposed to blueprints. You will have to write your own UFUNCTION which then uses the library functions.

And yes, I am using several C/C++ libraries in my project.

In addition I can’t think of a reason why you would want to use something low level like a TCP server in blueprints.

@Corneel i only use TCP socket as client to communicate with remote server.
If u want to make a TCP server, u should be able to implement this using the TCPListener class

@Mellnik I understand that part, I have several C++ functions that are exposed as blueprint nodes. I asked whether you have actually made the FTCPListener work.
@Fallonsnest yes I have tried many combinations of that class but the listener does not work as I described above.

So why would you want to see a plugin with a generic TCP library then?

That is not what I asked. You listed all the other libraries. I simply want a TCP Listener that use the Epic libraries (FTCPListener presumably). Apparently, it is not that simple because even
@Rama 's example seems to have issues in 4.20.

my apologies if this is too basic for some people. i am trying to connect plc (twincat3) to ue4 and apparently there are some options here for communication. plc has .cpp, .h, and dll’s. it also has plugins such as udp and tcp for real-time. i dont get the difference between these, but i am trying to use tcp. do u have any comments on that?