This was an individual portfolio assignment in the course "DATA2410 - Networking and cloud computing" at Oslo Metropolitan University.
We were tasked with creating a Python chat room with bots and a host that could talk to each other through a TCP socket.
-
Start by running the server.py in a terminal window with the port as the argument.
-
The server will then go in listen-mode and wait for connections and let us know if somebody connects.
-
Open up at least one terminal for a bot, or as many as you see fit. Keep in mind that there are only 3 bots to choose from: Ash, Misty and Brock
-
One must also open one terminal for the host-client, aka. the user. More hosts are allowed, but only one is recommended for optimized use.
-
Start client.py in the new terminals with 3 arguments: IP-address, port and name. The name decides whether you're a bot or a host.
-
The chatroom should now be intact. The user can write whatever he/she desires, and the bot(s) will respond accordingly.
-
The bots will have seperate responses for a set of given verbs.
-
To disconnect, one can simply close the terminal windows. The host can also write "SHUTDOWN" to disconnect all clients and stop the server. The server will notify the clients when somebody disconnects.
- server.py: Hosts the chat room.
- Requires port number as argument:
python3 server.py 4242
- Type server.py -h for more info:
usage: server.py [-h] port Start the chat server and listen for incoming connections. Example: server.py 4242 positional arguments: port The port the server is running on (Integers only). optional arguments: -h, --help show this help message and exit
- Requires port number as argument:
- client.py: Bots and host
- Requires IP address/hostname, port number and client name as arguments. The client name can be anything, but will become a bot if a bot name is given.
python3 client.py localhost 4242 Steven
- Type client.py -h for more info:
usage: client.py [-h] IP port name Connect to the chat room. Example: client.py localhost 4242 Steven positional arguments: IP IP address of the server the client is connecting to. port The port the client is connecting to (Integers only). name The name of the client. Connect as a host or a bot(Ash, Misty or Brock) optional arguments: -h, --help show this help message and exit
- Requires IP address/hostname, port number and client name as arguments. The client name can be anything, but will become a bot if a bot name is given.