I used python to create a basic server. There was two client scripts, a network script, and a server script. The network script created a network class that connected that two clients to the server. The server was connected to both the clients and tracked the movement of two different colored squares.
Client 1/main code:
The client code created an instance of a client that was connected to the server. The class player was created to draw the player store the player's movements. The def draw helper function drew the square and the def move function used the arrow keys to move the square. Functions def read_posn and def make_posn were used to convert the posn data type from a string into an integer. There was a function called def redrawWindow which created the game window. The def main function ran the game, used a while loop to send the current posn of the square to the server, and used a for loop to handle quitting the game.
Client 2 Code:
The Client 2 code was the same of the client 1 code, which created another instance of a square in a different color.
Network Code:
The network code created a class that connected the clients to the server. It had a def GetPosn function, a def connect function, and a def send function which were all used to send information back to the object that connected them.
Server Code:
The server code created the server and the ports to connect to. It used the ip address of the laptop that I created the code on to run the server. Sockets are used to connect to ports and to check if ports are taken. A while loop is used to continuously check for any ports that are open or taken. If the port is taken, then it searches for an open port.
Server running:
Video: