#! perl -slw use strict; #use threads; use IO::Socket; $|++; my $page = do{ local $/; }; my $s = IO::Socket::INET->new( Listen => 1, LocalPort => 80 ); while( my $c = $s->accept ) { printf "Connection accepted from %s\n", $c->peerhost; # async { my $req = <$c>; printf "Request received: %s\n", $req; my( $act, $url, $mode ) = split ' ', $req; if( $act eq 'GET' ) { if( $url eq '/' ) { print $c $page; } else { print $c '404 Not found'; } } elsif( $act eq 'POST' ) { my $read = 0; print $c '200 OK'; print $c ''; print $req; while( defined( $_ = <$c> ) and length() !=2 ) { printf "%s", $_; $read = $1 if $_ =~ m[Content-Length: (\d+)]; } print "\n", '=' x 20; my $post; read( $c, $post, $read ); print $post; } else { print $c '404 Not found'; } print $c ''; shutdown( $c, 2 ); close $c; # }->detach; } __DATA__ HTTP/1.0 200 OK Date: Mon, 28 Feb 2012 22:38:34 GMT Server: Perl/IOSocket/BrowserUk Content-Length: 3057 Connection: close Content-Type: text/html; charset=iso-8859-1 A test

A test

A test paragraph.

select:
Radio: Yes No
Radio2: YesNo.
Select2:
________ABC
A -
B -
C -