Anonymous user
Hello world/Web server: Difference between revisions
→{{header|Perl}}: added simpler solution using an extra module
m (→{{header|Perl}}: changed message to HTML and added HTTP status code) |
(→{{header|Perl}}: added simpler solution using an extra module) |
||
Line 136:
}</lang>
Various modules exist for using sockets, including the popular IO::Socket which provides a simpler and more friendly OO interface for the socket layer.
{{libheader|IO::Socket::INET}}
<lang Perl>use IO::Socket::INET;
my $sock = new IO::Socket::INET ( LocalHost => "127.0.0.1",
LocalPort => "8080",
Proto => "tcp",
Listen => 1,
Reuse => 1, ) or die "Could not create socket: $!";
while( my $client = $sock->accept() ){
print $client "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";
close $client;
}</lang>
=={{header|PicoLisp}}==
|