SYNAPSE Project
Tom Kelliher, CS 318
Apr. 10, 2000
Will return exam Wednesday.
SYNAPSE project, due 4/24.
Exam.
- Discussion of project.
Finish socket calls. Start building servers.
- Simple Synchronous Capable Web Server.
- Serves: HTML, GIF, JPEG.
- Runs: CGI called via GET operation.
- Only handles the GET operation.
- Use server.pl as an example of how to initialize the
server's socket connection and extract client information (IP, hostname,
port).
- In your documentation, carefully explain each socket call.
- Other items expected in the documentation: program and subroutine
descriptions, descriptive variable names and descriptions,
separation between subroutines (use of whitespace), commentary within code
blocks, where appropriate.
Subroutine descriptions should describe input parameters and return values,
where appropriate.
- Design: top-down. Implementation and testing: bottom-up.
Plan to build two. First, an experimental prototype. Second, the project
to turn in.
Good design important: short subroutines, symbolic constants, don't do more
than required (e.g., reading an entire file in at once).
Vital to think about a build/test sequence:
- Get server listening on its port.
- Use telnet to send requests, server prints client information and
client request.
- Still using telnet, server now serves a single HTML file from
disk.
- Switch over to browser.
- Server now serves arbitrary HTML files.
- Server additionally server JPEG files. Then, GIF files.
- Server executes CGI files.
- Testing document. Minimally, exercise all code. 501, 404 status
codes.
- What to turn in. Late policy, point distribution.
This is a simplification, a starting point. Do not implement
directly from it.
Example client requests:
GET / HTTP/1.0
POST /handler.cgi?name=kelliher HTTP/1.0
The POST example is contrived. Not shown are the attribute lines, which
can be ignored.
Notes:
- Each request is terminated with
\r\n\r\n
.
- If the operation is anything other than GET, generate a 501 Not
Implemented status page.
- All path are relative to document root. If the path is non-existent,
generate a 404 Not Found status page.
- Association of path extension and content-type attribute.
If client request is GET / HTTP/1.0
server reply is:
HTTP/1.0 200 OK
Connection: close
Content-Type: text/html
<contents of document-root/index.html
Notes:
- Empty line separates reply header from reply body.
- If running a CGI, CGI generates content-type attribute.
Example of server reply on a 404:
HTTP/1.0 404 Not Found
Connection: close
Content-type: text/html
<HTML><HEAD>
<TITLE>404 File Not Found</TITLE>
</HEAD><BODY>
<H1>File Not Found</H1>
The requested URL <insert path here> was not found on this server.<P>
</BODY></HTML>
501 is similar.
- Server should work with both Netscape and IE.
- IE occasionally sends an empty request.
- Netscape occasionally closes a connection early.
This is handled by the PIPE handler.
- TERM handler gracefully shuts down open files and sockets when a
Ctrl-c is received.
You can use docs.tar as a sample web site. During build/test phase,
you may want to add/subtract files.
Thomas P. Kelliher
Mon Apr 10 09:13:56 EDT 2000
Tom Kelliher