26 | | In this setup, there is one host acting as a web server. To test that the webserver is up visit the web page of the Server host. To do this: |
27 | | * either press on the (i) button in Flack and then press the Visit button |
28 | | * or open a web browser and go to the webpage !http://<pcname>.emulab.net, in the above example this would be !http://pc484.emulab.net). |
| 26 | In this setup, there is one host acting as a web server. To test that the webserver is up visit the web page of the Server host, use either of the following techniques: |
| 27 | * Press on the (i) button in Flack and then press the Visit button, or |
| 28 | * Open a web browser and go to the webpage !http://<pcname>.emulab.net. In the above example this would be !http://pc484.emulab.net. |
112 | | Accept new connection from incoming client |
113 | | Parse HTTP request |
114 | | Ensure well-formed request (return error otherwise) |
115 | | Determine if target file exists and if permissions are set properly (return error otherwise) |
116 | | Transmit contents of file to connect (by performing reads on the file and writes on the socket) |
117 | | Close the connection (if HTTP/1.0) |
| 112 | * Accept new connection from incoming client |
| 113 | * Parse HTTP request |
| 114 | * Ensure well-formed request (return error otherwise) |
| 115 | * Determine if target file exists and if permissions are set properly (return error otherwise) |
| 116 | * Transmit contents of file to connect (by performing reads on the file and writes on the socket) |
| 117 | * Close the connection (if HTTP/1.0) |
121 | | 1) A multi-threaded approach will spawn a new thread for each incoming connection. That is, once the server accepts a connection, it will spawn a thread to parse the request, transmit the file, etc. |
122 | | |
123 | | 2) A multi-process approach maintains a worker pool of active processes to hand requests off to from the main server. This approach is largely appropriate because of its portability (relative to assuming the presence of a given threads package across multiple hardware/software platform). It does face increased context-switch overhead relative to a multi-threaded approach. |
124 | | |
125 | | 3) An event-driven architecture will keep a list of active connections and loop over them, performing a little bit of work on behalf of each connection. For example, there might be a loop that first checks to see if any new connections are pending to the server (performing appropriate bookkeeping if so), and then it will loop overall all existing client connections and send a "block" of file data to each (e.g., 4096 bytes, or 8192 bytes, matching the granularity of disk block size). This event-driven architecture has the primary advantage of avoiding any synchronization issues associated with a multi-threaded model (though synchronization effects should be limited in your simple web server) and avoids the performance overhead of context switching among a number of threads. |
| 121 | 1. A multi-threaded approach will spawn a new thread for each incoming connection. That is, once the server accepts a connection, it will spawn a thread to parse the request, transmit the file, etc. |
| 122 | 2. A multi-process approach maintains a worker pool of active processes to hand requests off to from the main server. This approach is largely appropriate because of its portability (relative to assuming the presence of a given threads package across multiple hardware/software platform). It does face increased context-switch overhead relative to a multi-threaded approach. |
| 123 | 3. An event-driven architecture will keep a list of active connections and loop over them, performing a little bit of work on behalf of each connection. For example, there might be a loop that first checks to see if any new connections are pending to the server (performing appropriate bookkeeping if so), and then it will loop overall all existing client connections and send a "block" of file data to each (e.g., 4096 bytes, or 8192 bytes, matching the granularity of disk block size). This event-driven architecture has the primary advantage of avoiding any synchronization issues associated with a multi-threaded model (though synchronization effects should be limited in your simple web server) and avoids the performance overhead of context switching among a number of threads. |