Just my 2 cents here.
The algorithm you have seems pretty solid to me. I’m not sure if you’re using winsocks or something else. Also not sure if you’re using UDP or TCP. If you’re using UDP you might want to add a check every few seconds to see if the clients are still responding, and/or perform a test to see how many packets are lost (make sure it’s in range for your game). A quick ping to make sure there wasn’t a disconnect, that way invalidated players could be taken out of the saved players list. Although TCP is more reliable for data packets, disconnects can still happen so you could do the same with a TCP connection. In the master server I would store all the players..but would also check every 60 seconds or so to see if the ip:port still responds to pings. I would add this because after a while your list of players could fill up with dropped connection player data, also if your match making ends up having some sort of user login/validation logic the server will think they’re already connected if they try to log back in after a disconnection event.
Q2: I’m not sure if you meant that you would code 500 host applications that are different than the master sever executable. I wouldn’t execute 500 applications at the start. This would use resources that aren’t needed until a game is actually matched. Also in this case I think you would end up having to setup a separate port for each application so that you could have 500 different listeners. This would also make you have to code the client to test every possible port to find an empty server game application. (However, if you had a single “master sever” clients could first connect to this and would be assigned port/host application to play on (possibly only executing new instances of the application as needed). Again, I not sure what your design plan was.) This is definitely doable.
I would code a single master server application as a multithreaded application, and code each host game as a thread in this application. I’d create a linked list of host game threads (or whatever structure you prefer) Every time two players were matched for a new game I would create a new node and spawn a new thread passing in the players
data. Since you’re limited by hardware I would probably code a max number of threads (available games). In this way games could be kept track of by a master server application and games could be added and removed from the linked list as needed. This would also give you the ability to check in on games. Test that the games haven’t disconnected. If so you could reclaim the game node and log the players out. After a while your list could fill up with dead games so you may want to code a process that
would walk the linked list every once and a while to make sure things are going ok. Maybe even later you could add some tests to make sure players aren’t cheating.
What I said above only works if you plan to have a single computer act as your server, if your plan was to have servers on several computers than you would need to do something different and have at least a server/host executable on each machine.