Runtime Change IP and Port of listen server

Hello!
How do I host a host a Listen Server on specific IP and Port on Runtime.
I tried uworld:listen()
Uworld:servertravel()
Engine: clienttravel()
And even cmd open mapname?listen?ip=192.168.1.6?port=1234
Only 127.0.0.1 and 7777 work on cmd…

The Host IP is set by your Router or Network Adapter not by Unreal Engine.

The port however can be set by Unreal Engine

1 Like

How do I change port in runtime?
Also how do I connect to 192.168.1.6:4321
When the listen server is hosted on 127.0.0.1:7777

127.0.0.1 is what is known as a localhost address. It can ONLY be used to connect to yourself as in connecting a client and a server that is running on the same PC.

The command for a client to join a server is simple the IP and port like 192.168.1.6:4321. Note that this is a local network IP so the client needs to already be on the same LAN as the server to be able to connect.

1 Like

When the server opens a new map with the option “listen” you just add “port=####” and separate each option with a “?”.
Like this
listen?port=7778

2 Likes

Let’s say if i input this cmd
open mapname?listen?port=1234

And i can connect to the server using
open 192.168.1.6:1234
Would I be able to connect?

If you are on another computer in the same network and provided there are no internal firewall rules blocking the connection then yes.

If you are on the same machine then you’d have to connect to 127.0.0.1

Try have a look at this thread, if you’re still confused about it.

2 Likes

Thanks!
But when I do
open mapname?listen?port=1234
It starts listening on wrong port 7777

And if i try to connect using
open 127.0.0.1:1234
It does not work

Only
open 127.0.0.1
Works, but connects on 7777 port

I don’t think you can define the port while opening a new level (although I am not sure). The only way I know of changing the default listen port is by tweaking the DefaultEngine.ini URL section OR launching the editor game with the -port option.

So if the server is on port 7777
I can only join on 192.168.1.6:7777

And is there not way to dynamically set port?