1 # example program: a single-request HTTP server
2 # listen for connections from clients on a server socket
3 # when a connection occurs, transfer it to a session socket
4 # read from it using channels
7 # After running it, navigate to localhost:8080. Your browser should display
8 # "SUCCESS!" and the server will terminate after one connection.
12 socket:num <- $open-server-socket 8080/port
13 $print [Mu socket creation returned ], socket, 10/newline
15 session:num <- $accept socket
16 contents:&:source:char, sink:&:sink:char <- new-channel 30
17 sink <- start-running receive-from-socket session, sink
18 query:text <- drain contents
19 $print [Done reading from socket.], 10/newline
20 write-to-socket session, [HTTP/1.0 200 OK
21 Content-type: text/plain
25 $print 10/newline, [Wrote to and closing socket...], 10/newline
26 session <- $close-socket session
27 socket <- $close-socket socket