Networking with UE4

Hello folks!

I didn’t find that much info on this topic despite the part that UE4 can act as a server, which the thing is I don’t want to archieve.

My team and me are working on a game with a client-server architecture. The question here, how to manage the outgoing and ingoing networking with the inbuilt possibilities of UE4.

I know there is the FSocket class, which is a good starting point, but for the people out here, is the networking library of UE4 enough? Or should we use a library for instance, boost.asio?

I’m looking forward to hearing from you and appreciate your help/info on this!
Sincerely

If you’re trying to make a multiplayer game, and you’re talking about networking in the context of game logic, then you probably don’t want to deal with low-level networking code at all. Instead you should read up on Replication, which is UE4’s way of sending data between clients and servers for multiplayer games. With replication, all the networking stuff happens automatically, and you can focus on making your game.

If you want to create servers for other things, or if you want to implement custom networking protocols, you can take a look at the FSocket API. All the relevant APIs are in /Engine/Source/Runtime/Sockets/. The socket code in Unreal Engine is very old, so there’s some additional helper code in /Engine/Source/Runtime/Networking/ to simplify some of the most common tasks.

If you want to build a distributed application that communicates over a local area network, you can take a look at /Engine/Source/Runtime/Messaging/, which provides APIs for a message bus. There is also the beginning of an RPC framework on top of this framework, called MessagingRpc, but it’s still in its infant stage.

As I understand, replication is used by the engine itself, what I’m trying to say the engine itself is started as a server to archieve this process or? This is something I don’t want to archieve, because we will have a standalone server which is doing his job(on data processing, working with a database and sending “results” back to the game client)

Well this is something I started looking at first. Currently I’m evaluating if it’s good for our purpose and how far we will get with it, but I think this will be more our starting point.

I know it’s always good to use present tools and Replication in UE is really nice but unfortunately this is something we wouldn’t implement.

If I missunderstood something, please tell me.

Sincerely

FSocket is your friend then. Check out the FTcpSocketBuilder helper class for creating sockets.

I have one more question on this. Where is the best place to have the networking?
I was thinking about to have it in PlayerController as it seems logical to me, though I did an example as an Actor.

I’d probably put the networking related code into a separate class, and then you can use that class where it is convenient, i.e. in the PlayerController.

This tutorial can help you : A new, community-hosted Unreal Engine Wiki - Announcements and Releases - Unreal Engine Forums,Receive_Binary_Data_From_an_IP/Port_Into_UE4,(Full_Code_Sample)

Depend of your need, but ActorComponent can be a cool place to embedded all your Network logic and plug it inside each actor which need your custom Replication, also use an Interface to check if this actor has the Network component.

Is it possible to re-use existing replication protocols in UE4 client and implement it in custom server? (not to invent those things from scratch)
Is there any description for such low-level API?

2 Likes