socket_inet.sf 496 B

123456789101112131415161718
  1. #!/usr/bin/ruby
  2. var inet = require('IO::Socket::INET');
  3. var sock = inet.new(
  4. LocalAddr => "127.0.0.1:8080",
  5. Listen => 1,
  6. Reuse => 1,
  7. );
  8. while (var client = sock.accept) {
  9. client.print ("HTTP/1.1 200 OK\r\n" +
  10. "Content-Type: text/html; charset=UTF-8\r\n\r\n" +
  11. "<html><head><title>Goodbye, world!</title></head>" +
  12. "<body>Goodbye, world!</body></html>\r\n");
  13. client.close;
  14. }