Sidef

 view release on metacpan or  search on metacpan

scripts/WWW/socket_inet.sf  view on Meta::CPAN

#!/usr/bin/ruby

var inet = require('IO::Socket::INET');

var sock = inet.new(
                LocalAddr => "127.0.0.1:8080",
                Listen    => 1,
                Reuse     => 1,
        );

while (var client = sock.accept) {
    client.print ("HTTP/1.1 200 OK\r\n" +
                "Content-Type: text/html; charset=UTF-8\r\n\r\n" +
                "<html><head><title>Goodbye, world!</title></head>" +
                "<body>Goodbye, world!</body></html>\r\n");
    client.close;
}



( run in 0.629 second using v1.01-cache-2.11-cpan-39bf76dae61 )