Connect via IP(v6) and Port

Hi,

I try to setup a really basic implementation of a matchmaking server.

I found two options to connect to a server via IP. the first is to execute “open ip” as a console command and to use PlayerController::ClientTravel (APlayerController::ClientTravel | Unreal Engine Documentation).

However, both options seem to work with IPv4 only and without Ports. But I’m not 100% sure about the port part, because I’m not sure I’m using the correct port. Which leads me to my second question. I’m using CreateSession of the default online subsystem to create a host. But I don’t see any way to know which port the server is using. (Create Session | Unreal Engine Documentation). Right now I try the port which is also used for the communication with the matchmaking server, because I know it’s resolving to the correct client (NAT) and application, but seems like the online subsystem is listening on a different port.

For now all clients and servers are in the same subnet, to prevent any problem with NAT.

The console command works with a port, too.
Just like in a browser:


000.000.0.0:port

Tried that, didn’t work, probably because it was the wrong port. Still need to know how to get the port used by the session. And it also doesn’t work with IPv6.

So, after some testing and other stuff I figured out how to get the Port.

However, connecting with ip and port is still not working and I tried the port stored in the session info.

How did you get the port?

Hi,

I just copied my whole “Stun Client Stuff” here: Unreal Sockets - Pastebin.com

I get the port in line 40, but first you need the socket, 32, but for that you need the ipnetdriver (20) and for that you need the netdriver (16) and for that you need the onlinesubsystem (5).

Also I tried to get the port in 14 “getportfromnetdriver” but if I remember correctly that’s just the preferred port for that netdriver and that instancename, so it’s not guaranteed to be that port (but maybe it was, I can’t remember).

Depending on what you what there is also

Session->SessionInfo->HostAddr->GetIP/GetPort

to get the port of an already active session.