I develop my own network multiplayer framework. I use both rest services and socket connections. I have an authoritative server. Which port numbers should I use for client-server connection? Is there any restricted ports for some countries? I plan to use just socket connections for all type of games. Should I use rest services dynamic single player games instead of socket connection?
I've always started at 5000, for no real reason than that's from one of the earliest networking tutorials I saw. I'll change if new info comes along though.
https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers Summary: Ports 0-1023 are reserved, should never be used. On linux they can't be used without super user privs. 1024 - 49151 are registered. Or actually reserved for registration, not all are actually in use. 49152–65535 are ephemeral, not assigned free to use for whatever. Ephemeral ports are used by quite a bit of software, usually on the server but sometimes on the client. If you use numbers from that range, you really need to write logic that picks an available port from a range, going down the range until you find one available. Because a lot of server daemons assign a local port for each connection from this range. Ephemeral ports on the client are generally a bad idea for games. Higher chance of conflict, and you really need those to be known/stable so users can unblock them if necessary. So I usually pick my ports from the registered list, using ones not actually in use. Chances of a conflict are low and you can have stable port numbers.
@snacktime Thanks for this info. I will use a port number just on the server side. There will be no socket listener on the client side. For each server, I need nearly 10 port numbers to listen to incoming connections. I plan to handle 10.000 CCU on a server. I hope each client connection uses the same port number on the server side. For example, each client will connect to the port 5555 on the server. I hope those connections will be handled on the serverside port 5555. I will test if the server creates another port for connection coming to port 5555. Is it advantageous to use rest services instead of a socket connection? If I use socket connection 5555 instead of a rest service, Will fewer players to be able to connect my server?
You're main issue will be how many messages per second the server will be sending to each of those 10k clients.