#!/usr/bin/perl -w use strict; use IO::Socket::INET; my $socket = IO::Socket::INET->new( LocalPort => 7788, Type => SOCK_STREAM, Reuse => 1, Listen => 10, ) or die "$!"; my ( $c, $content, $content_length, $server_type, $date, $text, $html_document, $header ); $text = &prepare_content; &serve; sub serve() { while ($c=$socket->accept()) { print $c "$text\n"; close($c); } close($socket); } sub prepare_content() { $html_document = $ARGV[0]; open(DOCUMENT, $html_document); my @content = ; close(DOCUMENT); $server_type = "Jazserv/1.0"; foreach my $temp (@content) { $content = $content . $temp; } $content_length = length($content); $date = `date`; print $content; $header = " HTTP/1.1 200 OK Server: $server_type ETag: \"\" Accept-Ranges: bytes Content-Length: $content_length Connection: close Content-Type: text/html; charset=ISO-8859-1 "; return "$header" . "$content"; }