Download

Proper way to make server browser (sockets?)

Hello all. I’ve spent the last couple weeks searching in my free time for how to make a server browser. I know how to connect to a server using the ?ipaddress method and have seen many many tutorials show how to make one that is LAN only. What I need for an actual game is to connect to a system I host somewhere.

I’m not going to be using steamworks for cross-compatibility. I’ve also done some small socket programming before in with a c server and c++ client outside of Unreal.

Having seen no examples, what is the way people usually do this? Does Unreal have it’s own socket programming interface or should I program it directly like I would outside of UE4? Is there something built in to make this easier or at least one example out there? Do people usually make them with web interface like PHP or C or something else?

Thanks!

-Shawn

You can use Unreal built-in online session management without using Steam. There’s a base platform agnostic online subsystem module. There’s no need to use sockets.

The proper way would be to create a new implementation of the built-in online subsystem interface. You can copy the code from OnlineSubsystemNull to get started as a base, and then replace different functions (like registering, listing, and joining servers) with however you want to handle it (e.g. an https request to some master server [you’ll need to write the master server API as well]). You probably shouldn’t need to touch raw sockets at all unless you’re doing something weird, there’s built in APIs for most networking tasks that are cross platform.

Thanks for the help pointing me in the right direction. This will give me some direction into what to research.

If anyone knows of some tutorials or examples that would really help speed things along. I’ve only programmed “pure” c++ in the past and the whole pile of UE4 files is a bit intimidating/time consuming.

By default you don’t actually have to use any service provider if you don’t want to, the null subsystem can handle finding other sessions of the same game type. (ShooterGame in the ‘Learn’ tab uses the nullsubsystem for that :)) Some specific platforms are already integrated (e.g, steam for example), and you can register sessions with the steam service if you want to. Entirely up to you really :slight_smile:

Honestly, the online subsystem is probably one of the most intimidating parts of UE4 - still don’t fully understand it myself :slight_smile:

EDIT: So many smileys in one post…

Thanks for the smiles. Yea I’ve looked at and duplicated what they did in ShooterGame as well as a number of youtube vids and the official documentation. The issue is these only work on LAN out of the box. I need a way to get a list that also includes remote IP addresses to plug in to the connection.

Haven’t actually looked at the code but sounds like the Null subsystem is just doing a UDP broadcast, which won’t extend past the router/NAT.

You’ll have to re-implement this part of the interface. Change the UDP broadcasts with calls to a master server API.

AFAIK ShooterGame works with online games too, but then again… I never tested that. Maybe it doesn’t :o

I’d maybe start by looking at the difference between the null and the steam subsystem, since you can register sessions with steam servers.

ShooterGame only works across internet if you use the Steam OSS. If you use OSS Null then you are limited to Lan only (local subnet).

One alternative (if you dont need voice) is to just use the console commands and connect directly using open <ipaddres>. This bypasses the entire OSS module. This will work across the internet as long as the server has port 7777 open. If you use this method you could build your own server browser code using the VaRest plugin or roll your own. Then write a simple web service on the host side to list the servers you have.