r1n0 has asked for the wisdom of the Perl Monks concerning the following question:

Hello, I have a question about IO::Socket use. To provide some extra background, and answer "Why I am not using other Server modules?", I am writing a specialized proxy server that will handle quite a few things, and it is going to have special functionality that the other server modules as well as other proxy modules do not have in them. I have written a perl script that acts as a poor man's version of a webserver. I am using IO::Socket to setup the server like such:

$server = IO::Socket::INET->new (
LocalPort => 8080,
Type => SOCK_STREAM,
Reuse => 1,
Listen => 10) or die "$@\n\n\n";

binmode $server;
print "\n\nServer Started...\n";
print "\t listening on port 8080......\n\n";

while ($client = $server->accept()) {
$client->autoflush(1);
binmode($client);

next if my $pid = fork;
die "fork - $!\n\n" unless defined $pid;

$client_line = <$client>;
( $method, $hostAddr, $httpVer ) = $client_line =~ /^(\w+) +(\S+) +(\S+)/;

Also, I check to see what method the user is using to send me data (GET, POST, CONNECT). I have the system process the GET calls without any problem, but I can't seem to get server to accept all the POST input from a client. What I want to do is accept all input from the post prior to processing it. I assume this is similar to how a larger server does it. Can someone provide me a sample for having the server chat back to the client to get all POST information? I would like to say thank you in advance for any help. Thanks, R1n0
  • Comment on IO::Socket use in Small Web Server for POST/GET methods

Replies are listed 'Best First'.
Re: IO::Socket use in Small Web Server for POST/GET methods
by ikegami (Patriarch) on Sep 18, 2008 at 03:32 UTC
    Why don't you use an existing poor mans web server, such as HTTP::Daemon

      To say nothing of the web server for those of moderate means, POE::Component::Server::HTTP.

      The cake is a lie.
      The cake is a lie.
      The cake is a lie.

      I would like to thank everyone for their input, but I would like to provide some extra background, and answer "Why I am not using other Server modules?", I am writing a specialized cache server that will handle quite a few things, and it is going to have special functionality. I know of the other modules, but being this is my first perl use of IO::Socket... I would like to learn as much about it as possible. I plan on getting familiar with the other modules in the future. Learning IO::Socket will help with other things I planning on doing in the future, too.
        Starting with one of the aforementioned modules and modifying it to your needs still satisfies your goals.