Update S11: Practice 3 authored by Sergio Najib's avatar Sergio Najib
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
# Session 11: Practice 3 # Session 11: Practice 3
* **Time**: 2h * **Time**: 2h
* **Date**: XXXX, XX-XX-2023 * **Date**: Wednesday, 06-03-2024
* **Goals**: * **Goals**:
* Practicing on the programming of servers * Practicing on the programming of servers
* Develop our own server for working with DNA sequences * Develop our own server for working with DNA sequences
...@@ -63,11 +63,11 @@ There is a special **IP** address: **127.0.0.1**, which is used to identify **yo ...@@ -63,11 +63,11 @@ There is a special **IP** address: **127.0.0.1**, which is used to identify **yo
We will implement the so called **Seq Server**, and develop some clients to test it. While developing the server, we will use the **echo** and **nc** linux commands for **sending messages** to the **server**. But you can also do it from your own client if you like. We will implement the so called **Seq Server**, and develop some clients to test it. While developing the server, we will use the **echo** and **nc** linux commands for **sending messages** to the **server**. But you can also do it from your own client if you like.
The server will be stored in a file called **Seq-Server.py** within a folder with name **P03**. You will need to use the **Seq1 module** developed in **P01**, and extend it. As you can see, we are building on previous work. The server will be stored in a file called **SeqServer.py** within a folder with name **P03**. You will need to use the **Seq1 module** developed in **P01**, and extend it. As you can see, we are building on previous work.
### Exercise 1: PING ### Exercise 1: PING
* **Filename:** P03/Seq-server.py * **Filename:** P03/SeqServer.py
Let's start programming a server that implements the **PING command**. The client will send a message with the word **PING**; then, the server **parses** the request message so if the PING command is **detected**, it generates the response message **"OK!\\n"**. Also, it needs to **print on the console** the message "PING command!" in green, and then the response message in white. Let's start programming a server that implements the **PING command**. The client will send a message with the word **PING**; then, the server **parses** the request message so if the PING command is **detected**, it generates the response message **"OK!\\n"**. Also, it needs to **print on the console** the message "PING command!" in green, and then the response message in white.
...@@ -87,9 +87,9 @@ And this is what we should get in the **Server's console**: ...@@ -87,9 +87,9 @@ And this is what we should get in the **Server's console**:
### Exercise 2: GET ### Exercise 2: GET
* **Filename:** P03/Seq-Server.py * **Filename:** P03/SeqServer.py
Modify the Seq-server to implement the **GET command**. The client sends a message with the word **GET** followed by a **number** between **0** and **4**. The server will return a **response message** with a **sequence** associated to that number. These sequences are for testing purposes, so you can use whatever sequences you want; stored them into a **list** that the server uses to index with the received parameter. Modify the SeqServer to implement the **GET command**. The client sends a message with the word **GET** followed by a **number** between **0** and **4**. The server will return a **response message** with a **sequence** associated to that number. These sequences are for testing purposes, so you can use whatever sequences you want; stored them into a **list** that the server uses to index with the received parameter.
Use the following command to test the server: Use the following command to test the server:
...@@ -109,7 +109,7 @@ And this is what we should get in the **Server's console**: ...@@ -109,7 +109,7 @@ And this is what we should get in the **Server's console**:
### Exercise 3: INFO ### Exercise 3: INFO
* **Filename:** P03/Seq-server.py * **Filename:** P03/SeqServer.py
Modify the Seq server for implementing the **INFO command**. The client sends a message with the word **INFO** followed by a sequence. The server will return a **response message** with information about that sequence. This information should be obtained using the **Seq Class**. Modify the Seq server for implementing the **INFO command**. The client sends a message with the word **INFO** followed by a sequence. The server will return a **response message** with information about that sequence. This information should be obtained using the **Seq Class**.
...@@ -129,7 +129,7 @@ And this is what we should get in the **Server's console**: ...@@ -129,7 +129,7 @@ And this is what we should get in the **Server's console**:
### Exercise 4: COMP ### Exercise 4: COMP
* **Filename:** P03/Seq-server.py * **Filename:** P03/SeqServer.py
Upgrade the server to respond to the **COMP command**. The client sends a message with the word **COMP** followed by a sequence (the argument of the command). The server will return a **response message** with the complement of that sequence. As always, it must be obtained using the **Seq Class**. Upgrade the server to respond to the **COMP command**. The client sends a message with the word **COMP** followed by a sequence (the argument of the command). The server will return a **response message** with the complement of that sequence. As always, it must be obtained using the **Seq Class**.
...@@ -149,7 +149,7 @@ And this is what we should get in the **Server's console**: ...@@ -149,7 +149,7 @@ And this is what we should get in the **Server's console**:
### Exercise 5: REV ### Exercise 5: REV
* **Filename:** P03/Seq-server.py * **Filename:** P03/SeqServer.py
Modify the server to implement the **REV command**. The client sends a message with the word **REV** followed by a sequence. The server will return a **response message** with the reverse of the sequence. It must be obtained using the **Seq Class**. Modify the server to implement the **REV command**. The client sends a message with the word **REV** followed by a sequence. The server will return a **response message** with the reverse of the sequence. It must be obtained using the **Seq Class**.
...@@ -169,7 +169,7 @@ And this is what we should get in the **Server's console**: ...@@ -169,7 +169,7 @@ And this is what we should get in the **Server's console**:
### Exercise 6: GENE ### Exercise 6: GENE
* **Filename:** P3/Seq-Server.py * **Filename:** P3/SeqServer.py
Work on the Seq server so it responds to the **GENE command**. The client sends a message with the word **GENE** followed by a specific (and valid) **gene name**: U5, ADA, FRAT1, FXN, or RNU6_269P. The server will return a **response message** with the whole sequence corresponding to that gene. It must be obtained using the **Seq Class** (and reading the gene from the corresponding file). Work on the Seq server so it responds to the **GENE command**. The client sends a message with the word **GENE** followed by a specific (and valid) **gene name**: U5, ADA, FRAT1, FXN, or RNU6_269P. The server will return a **response message** with the whole sequence corresponding to that gene. It must be obtained using the **Seq Class** (and reading the gene from the corresponding file).
...@@ -261,7 +261,7 @@ The session is finished. Make sure during this week that everything in this list ...@@ -261,7 +261,7 @@ The session is finished. Make sure during this week that everything in this list
* [ ] You have all the items of S10 checked! * [ ] You have all the items of S10 checked!
* [ ] Your working repo contains the **P03** folder with the following files: * [ ] Your working repo contains the **P03** folder with the following files:
* [ ] Seq-server.py * [ ] SeqServer.py
* [ ] test-client.py * [ ] test-client.py
* [ ] All the previous files have been pushed to your remote Gitlab repo * [ ] All the previous files have been pushed to your remote Gitlab repo
... ...
......