Skip to content

Session 9: Practice 2

Juan Gonzalez-Gomez edited this page Feb 26, 2020 · 40 revisions

Session 9: Practice 2

  • Time: 2h
  • Date: Wednesday, Feb-26th-2020
  • Goals:
    • Practicing with the creation of clients
    • More Practicing on creating classes and objects
    • Learn how to run servers and clients on the same machine
    • Get familiar with the typical socket and network errors that will occur

Contents

Introduction

The goal of this practice is to gain experience running servers and clients in the same computer. We will develop python programs (clients) that send messages and sequences to other servers

For making it easier to send the messages, we will develop the class Client located in the Client0 module (File Client0.py)

Method Parameters Return Description
__init__(ip, port) IP: String, Port: Integer None Object Constructor. Stores the IP and Port values inside the object
__str__() none String It returns the string: "Connection to SERVER at {ip}, PORT: {port}", where the {ip} and {port} are the server's ip and port respectivelly
ping() None None It prints the "OK" message on the console. It is just for testing the module
talk(msg) msg: String to send to the server The response message from the server It creates a new socket, connects to the server, sends the message, receive the response message from the server and closes the socket
debug_talk(msg) msg: String to send to the server The response message from the server It works the same than the talk method, but it prints on the console both the message sent to the server and the response received, in different colors

As always, this class will be created step by step in the exercises. The process is guided

Exercises

We will implement the Client Class and develop some example programs to test it against the server

Exercise 1

  • Filename:
  • Description:
  • TODO
  • Modulo client: funcion send. Make the module work with simple strings

Change the server so that only the receive message is shown... (in a different color)

Exercise 2

  • Open a sequence from a file (ADA or whatever), calculate its complement, divide it into pieces of 20 bases and send to the server....

Exercise 3

  • Open all the genes and send them to the server

Exercise 4

  • Launch two servers. Open a gene. Read 20 bases. If the initial base is 'A' or 'T' is sent to the server 1, if the base is 'C' or 'G' it is sent to the other server

END of the session

The session is finished. Make sure, during this week, that everything in this list is checked!

  • You have all the items of the session 6 checked!
  • Your working repo contains the P1 Folder with the following files:
    • Ex1.py
    • Ex2.py
    • Ex3.py
    • Ex4.py
    • Ex5.py
    • Ex6.py
    • Ex7.py
    • Ex8.py
    • Ex9.py
    • Ex10.py
    • Seq0.py
  • All the previous files have been pushed to your remote Github repo

Author

Credits

  • Alvaro del Castillo. He designed and created the original content of this subject. Thanks a lot :-)

License

Links

Clone this wiki locally