-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtasks.txt
More file actions
53 lines (33 loc) · 1.57 KB
/
tasks.txt
File metadata and controls
53 lines (33 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
Session 4 Homework
==================
Required Tasks:
---------------
* Complete the code in ``echo_server.py`` to create a server that sends back
whatever messages it receives from a client
* Complete the code in ``echo_client.py`` to create a client function that
can send a message and receive a reply.
* Ensure that the tests in ``tests.py`` pass.
To run the tests:
* Open one terminal while in this folder and execute this command:
$ python echo_server.py
* Open a second terminal in this same folder and execute this command:
$ python tests.py
Optional Tasks:
---------------
Simple:
* Write a python function that lists the services provided by a given range of
ports.
* accept the lower and upper bounds as arguments
* provide sensible defaults
* Ensure that it only accepts valid port numbers (0-65535)
Challenging:
* The echo server as outlined will only process a connection from one client
at a time. If a second client were to attempt a connection, it would have to
wait until the first message was fully echoed before it could be dealt with.
Python provides a module called `select` that allows waiting for I/O events
in order to control flow. The `select.select` method can be used to allow
our echo server to handle more than one incoming connection in "parallel".
Read the documentation about the `select` module
(http://docs.python.org/3/library/select.html) and attempt to write a second
version of the echo server that can handle multiple client connections in
"parallel". You do not need to invoke threading of any kind to do this.