RiptideNetworking / Riptide

Lightweight C# networking solution for multiplayer games.
https://riptide.tomweiland.net
MIT License
1.14k stars 144 forks source link

Feature request: For Server, allow the IP Address to be specified #146

Closed Jeroen-R closed 2 months ago

Jeroen-R commented 3 months ago

A server can have multiple IP addresses. Some IP addresses are for internal use / management, while others are public facing (listening for requests from game clients).

On the Riptide Server object I don't see a property to specify the address to listen on, so what will happen if I stick it on a server with multiple IP Addresses? Will it pick one of the address randomly, or the first one it encounters?

E.g. in the following code I would expect to specify both the ip address (or better, hostname) to listen on and the port number.

            Server = new Server();
            Server.Start(port, maxClientCount);

I don't think this is related to a specific operating system. I am developing on mac os, if I take this into production it will most likely run on Linux.

tom-weiland commented 3 months ago

what will happen if I stick it on a server with multiple IP Addresses

It should listen on all of them, as it binds to the IPAddress.Any value (aka 0.0.0.0).

If this is not desirable for whatever reason and you only want to listen on a specific address, you can pass that address to the UdpServer constructor. Server = new Server(); would become something like this:

Server = new Server(new UdpServer(ipAddressToListenOn));

I don't think there is a way to have it listen on/bind to more than one specific address.