Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brettbuddin/376947 to your computer and use it in GitHub Desktop.
Save brettbuddin/376947 to your computer and use it in GitHub Desktop.
conn = new Socket;
while (true) {
// listen on port 80
if (conn.listen (8000)) {
// wait forever for a connection
var incoming;
while (incoming == null) {
incoming = conn.poll();
}
// discard the request
conn.read();
// Reply with a HTTP header
incoming.writeln ("HTTP/1.0 200 OK");
incoming.writeln ("Content-Type: text/html");
incoming.writeln();
// Transmit a dummy homepage
incoming.writeln ("<html><body><h1>Homepage</h1></body></html>");
// done!
incoming.close();
delete incoming;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment