Running The UDP Server & Client Together
We've spent the last few lessons writing code for a very basic client and a server. Let's see these in action in this lesson!
We'll cover the following
Connecting the Two
We’ll run both together in one file called udp.py
instead of running them separately. We’ve written some python code in the main function that allows you to specify which function you want the code to run, the server
or the client
.
To run the code, you would need to follow these steps:
- Type your code and when you are ready to run the program, click on Run. The server code should start up automatically.
- Open another terminal by clicking on +
- Type the command
python3 /usercode/udp.py client
Note that it can beserver
in place ofclient
. - Enter the text in the client window and see the effect.
- If the program is not running to your satisfaction:
- Kill the running server program by typing the break sequence
ctrl+c
orcommand+c
in both of the terminal windows. - Change the code
- Click on Run.
- Type command
python3 /usercode/udp.py server
andpython3 /usercode/udp.py client
in the first and second terminal window, respectively. Go back to step 4.
- Kill the running server program by typing the break sequence
Every time you make a change to the code you must click run for the changes to take effect.
Get hands-on with 1400+ tech skills courses.