albertaloop / T_SWE_2022_2023

Software for AlbertaLoop's first-generation pod.
MIT License
3 stars 0 forks source link

Test UDP socket communication in Python #11

Closed Iyury1 closed 2 years ago

Iyury1 commented 2 years ago

Summary

A short explanation on socket programming is located here: https://docs.google.com/document/d/1O2KUQOYpamOuhSZEWvoNXSt8WOrRuuixgkseU2PS6-8/edit?usp=sharing

The above document links to a website with an example of client - server communication. https://pythontic.com/modules/socket/udp-client-server-example

The example shows two separate Python programs, one for a client and one for a server. The idea is that you would run both programs at the same time, and be able to pass messages between the two programs using sockets. This works because the IP address set to each socket is the "loopback address" 127.0.0.1 which a computer uses to refer itself.

For this task, copy the client and server examples, run them as separate programs and verify messages can be successfully passed between both programs. The example code will have to be modified slightly to achieve this.

After testing the separate prorgams, create two Python classes: "Client" and "Server", and a third Python class called "UDPModule". The "Client" and "Server" classes will contain the code from the previously tested example. However, the socket they use should be contained within the "UDPModule" class. The "UDPModule" should also contain instances of the "Client" and "Server" classes, so each class will have access to the socket.

Create a new test program that performs the same test as before except using the same socket contained in the "UDPModule" class. That way only one program will need to run for this test.

Acceptance Criteria