Nov 3, 2015

Project Cartographer – 2 clients or a server on the same network? (Or PC)

So originally you were unable to run 2 clients or 1 client and a server on the same network or same machine,
Now I’ve come up with some what of a fix and it’s pretty messy but it works!

Basically the way I was handling things previously you couldn’t run multiple clients on the same network or same PC even due to the fact that everything was binding to the same port and there were tons of comparisons and identification systems which would identify people based on their WAN IP address instead of some other unique identifier.

Now that I’ve changed the code to identify people differently and added a “server” option to the INI which you’re expected to set in one client/server on the network it will re-bind ports differently.

To explain if I want to run a server on my network I’ll leave it as “server = 0”, I know it’s kind of backwards…

This will cause my server to bind to standard ports 1000,1001,1005,1006.

Now when I launch my client and I set “server = 1”,

My client will bind to 1100,1101,1105,1106 and the rest of the network code in every other client and server will handle this appropriately based on data of where they receive the connection from, what this may break however is the ability to make a lobby due to the fact naturally when trying to connect to lobbies clients will attempt to use the standard ports.

So essentially you can only have 1 host per network at the moment, though this needs to be looked into in a less messy/sloppy manner so that we can run multiple instances of a dedicated server on a single system.

The only idea that I have to brain storm on with this is sending the port with the broadcast packets and having each client read/understand this,

The problem is at this point this is becoming less Universal and more geared towards Halo 2 which isn’t necessarily a horrible thing, just requires a lot of re-coding of the base.

And may mean that in the future I will have two separate versions one specifically geared towards Halo 2 and another which is universal for all XLive games.

For those who understand python read on…

There were also minor modifications I’ve had to make to the master server list which changed how users were stored,

Originally I stored users when they initially made a halo 2 specific “broadcast-search” packet.

In general this is the way LAN configurations in games should work…

Client->Broadcast to (Entire Local Network) -> Server gets packet and sends reply with information.

Right now the way the code works on this end is simply replacing with the “broadcast server” or “master server list”.

The way I stored the users was based on their remote IP without their port, now we just store the self.client_address tuple into the dict and use that.

Basically since each user would be now using a different port we combine the two to uniquely identify them, the way I was doing things previously would overwrite their user in the dict causing them not to be able to see the server… just a lesson to myself in bad programming practices attempting to identify people by IP addresses which I did a lot starting out with this project.


Server and client running on the same host.

Leave a comment