You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: _labs/concurrent-http-server.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,7 @@ Use the GitHub Classroom link posted in the Teams channel for the lab to accept
20
20
21
21
For this lab, you will be extending your HTTP server to handle multiple clients _at once_. The rest of your server will stay the same. There are multiple ways of supporting multiple clients. A typical approach is to spawn a new thread or process for each client that connects. That thread or process is responsible for communicating with a specific client. There is another approach that uses a system call (`poll` or `select`) to determine which sockets are ready to receive data from or write data to. Since with socket programming, most of the time your program is waiting around for the sockets to send or receive data, this allows your program to handle multiple sockets at once. Instead of creating a new thread or process for each client socket, one process keeps track of many sockets at once.
22
22
23
-
For this lab, you are required to implement a concurrent server in three ways: using threads, using a thread pool, and using `select`. Using standard threads, when a new request comes in, a thread is created and the socket is passed to that thread. The newly spawned thread is now responsible for receiving and sending data while the main thread is still accepting new clients. With a thread pool, you create a bunch of threads before starting your server and hand tasks (i.e., new clients) to threads that are idle. As mentioned in lecture, threads have their own set of issues, largely shared memory. To limit these issues, try to use local variables as much as possible. You should not need to use mutex/locks in this lab! For the `select` implementation, you will need to use the [`select` call](https://docs.python.org/3/library/selectors.html) to determine which sockets are ready to read from or write to. This is a more advanced technique and requires a good understanding of how sockets work. You will need to maintain a list of all the client sockets that are connected to your server and use `select` to determine which sockets are ready for reading or writing.
23
+
For this lab, you are required to implement a concurrent server in three ways: using threads, using a thread pool, and using `select`. Using standard threads, when a new request comes in, a thread is created and the socket is passed to that thread. The newly spawned thread is now responsible for receiving and sending data while the main thread is still accepting new clients. With a thread pool, you create a bunch of threads before starting your server and hand tasks (i.e., new clients) to threads that are idle. As mentioned in lecture, threads have their own set of issues, largely shared memory. To limit these issues, try to use local variables as much as possible. You should not need to use mutex/locks in this lab! For the `select` implementation, you will need to use the [`select` call](https://docs.python.org/3.12/library/selectors.html) to determine which sockets are ready to read from or write to. This is a more advanced technique and requires a good understanding of how sockets work. You will need to maintain a list of all the client sockets that are connected to your server and use `select` to determine which sockets are ready for reading or writing.
24
24
25
25
As part of writing a well behaving server, you will need to appropriately handle the threads when you are exiting (the user hits `ctrl-c`). This allows your server to finishing handling clients that have already connected before shutting down the server. To do this, you must join all spawned threads.
26
26
@@ -65,13 +65,13 @@ Run the benchmark **3 or more times** and report the best run. You should turn o
65
65
66
66
## Requirements
67
67
68
-
- You must use Python 3.10 for this lab.
68
+
- You must use Python 3.12 for this lab.
69
69
70
70
- The name of your program must be named `http_server.py`.
71
71
72
72
- You must be able to handle multiple concurrent clients at once using threads and a thread pool.
73
73
74
-
- You can only use the low-level [threading.Thread](https://docs.python.org/3/library/threading.html#thread-objects) objects. All high-level concurrency libraries like [concurrent.futures](https://docs.python.org/3/library/concurrent.futures.html) is not allowed. Python has implementations of thread pools, but you must implement these yourself to get the credit.
74
+
- You can only use the low-level [threading.Thread](https://docs.python.org/3.12/library/threading.html#thread-objects) objects. All high-level concurrency libraries like [concurrent.futures](https://docs.python.org/3.12/library/concurrent.futures.html) is not allowed. Python has implementations of thread pools, but you must implement these yourself to get the credit.
75
75
76
76
- Add the `-c`/`--concurrency` flags to your program. If the concurrency flag is not provided, the default value should be `thread`.
77
77
@@ -98,8 +98,8 @@ To submit your code, upload it to Gradescope.
Copy file name to clipboardExpand all lines: _labs/http-server.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -48,11 +48,11 @@ Then all requests would be relative to the `www` folder. The previous request wo
48
48
49
49
## Requirements
50
50
51
-
- You must use Python 3.10 for this lab.
51
+
- You must use Python 3.12 for this lab.
52
52
53
53
- You **can not use any third party Python libraries** for this lab. If you have to `pip install` or clone any repos, in order to import a library, stop. The only exception is the formatter, [Black](https://github.com/psf/black), which you have to `pip install`. However, you do not use it in your code.
54
54
55
-
- For all socket related tasks, you must only use the [low-level `socket` interface](https://docs.python.org/3/library/socket.html) that Python provides. No high-level server socket interfaces are allowed.
55
+
- For all socket related tasks, you must only use the [low-level `socket` interface](https://docs.python.org/3.12/library/socket.html) that Python provides. No high-level server socket interfaces are allowed.
56
56
57
57
- The name of your program must be named `http_server.py`.
Copy file name to clipboardExpand all lines: _labs/nibbletorrent-peer.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -246,7 +246,7 @@ Here is a diagram showing the general interactions between the different compone
246
246
247
247
## Requirements
248
248
249
-
- You must use Python 3.10 for this lab.
249
+
- You must use Python 3.12 for this lab.
250
250
251
251
- The only third-party Python library you are allowed to use in this lab is [requests](https://requests.readthedocs.io/en/latest/). That way you don't have to write your own HTTP client. All other third-party libraries are off limits.
252
252
@@ -304,8 +304,8 @@ To demonstrate this, follow these steps:
304
304
305
305
-[How to get your private IP address](https://stackoverflow.com/questions/166506/finding-local-ip-addresses-using-pythons-stdlib/)
306
306
307
-
-[Parsing JSON in Python](https://docs.python.org/3/library/json.html)
307
+
-[Parsing JSON in Python](https://docs.python.org/3.12/library/json.html)
308
308
309
-
-[Good way of creating a TCP server in Python](https://docs.python.org/3/library/socketserver.html)
309
+
-[Good way of creating a TCP server in Python](https://docs.python.org/3.12/library/socketserver.html)
310
310
311
311
-[Converting hex strings to bytes](https://stackoverflow.com/questions/5649407/how-to-convert-hexadecimal-string-to-bytes-in-python)
Copy file name to clipboardExpand all lines: _labs/simple-tls.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -137,7 +137,7 @@ optional arguments:
137
137
138
138
## Requirements
139
139
140
-
- You must use Python 3.10 for this lab.
140
+
- You must use Python 3.12 for this lab.
141
141
142
142
- The only third-party Python library you are allowed to use in this lab is [cryptography](https://cryptography.io/en/latest/), and the two modules I am providing, `crypto_utils.py`, and `message.py`. You shouldn't have to use the cryptography library directly if you plan on using `crypto_utils.py` All other third-party libraries are off limits.
143
143
@@ -167,7 +167,7 @@ To submit your code, upload it to Gradescope.
Copy file name to clipboardExpand all lines: _labs/tcp-server.md
+9-9Lines changed: 9 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -70,7 +70,7 @@ Your server will be designed to block forever. Once it has handled one client, i
70
70
71
71
### Logging
72
72
73
-
Like the previous labs, I strongly encourage you to use logging to help debug your program and understand its flow. Python provides a powerful [logging library](https://docs.python.org/3/howto/logging.html). Spend some time learning it and it will pay off later.
73
+
Like the previous labs, I strongly encourage you to use logging to help debug your program and understand its flow. Python provides a powerful [logging library](https://docs.python.org/3.12/howto/logging.html). Spend some time learning it and it will pay off later.
74
74
75
75
76
76
## Objectives
@@ -82,11 +82,11 @@ Like the previous labs, I strongly encourage you to use logging to help debug yo
82
82
83
83
## Requirements
84
84
85
-
- You must use Python 3.10 for this lab (and all other Python labs).
85
+
- You must use Python 3.12 for this lab (and all other Python labs).
86
86
87
87
- You **can not use any third party Python libraries** for this lab. If you have to `pip install` or clone any repos, in order to import a library, stop. The only exception is the formatter, [Black](https://github.com/psf/black), which you have to `pip install`. However, you do not use it in your code.
88
88
89
-
- For all socket related tasks, you must only use the [low-level `socket` interface](https://docs.python.org/3/library/socket.html) that Python provides. No high-level server socket interfaces are allowed.
89
+
- For all socket related tasks, you must only use the [low-level `socket` interface](https://docs.python.org/3.12/library/socket.html) that Python provides. No high-level server socket interfaces are allowed.
90
90
91
91
- The name of your program must be named `tcp_server.py`.
92
92
@@ -130,14 +130,14 @@ To submit your code, upload it to Gradescope.
130
130
131
131
## Resources
132
132
133
-
-[socket — Low-level networking interface](https://docs.python.org/3/library/socket.html). Make sure to look at all of the functions available to you.
133
+
-[socket — Low-level networking interface](https://docs.python.org/3.12/library/socket.html). Make sure to look at all of the functions available to you.
0 commit comments