jdtoronto has asked for the wisdom of the Perl Monks concerning the following question:
Following your answers to my question of yesterday in Adding HTTP server to Windows App - suggestions please!, I have tried some test code and have an issue which I do not understand. I am using latest ActiveState Perl (5.8.7 I think it is) on Windows XP sp1. Using the example code from the HTTPServer POD...
#!/usr/bin/perl -w use strict; use Net::HTTPServer; my $server = new Net::HTTPServer( port => 6789, log => "STDOUT" ); $server->RegisterURL( "/foo/bar.pl", \&test ); my $port = $server->Start(); $server->Process(); if ($port) { print "Port: $port\n"; } sub test { my $env = shift; my $res; $res = "<html>\n"; $res .= " <head>\n"; $res .= " <title>This is a test</title>\n"; $res .= " </head>\n"; $res .= " <body>\n"; $res .= " <pre>\n"; foreach my $var ( keys ( %{$env})) { $res .= "$var -> ".$env->{$var}."\n"; } $res .= " </pre>\n"; $res .= " </body>\n"; $res .= "</html>\n"; return ["200", (), $res ]; }
and we are back to prompt.INIT: Starting the server INIT: Attempting to listen on port 6789 2005/06/28 15:32:25 - Server running on port 6789 PROC: Process: type(single) PROC: Wait for 10 seconds PROC: Do we block? 1 PROC: Wait for 10 seconds PROC: Incoming traffic PROC: We have a client, let's treat them well. Your vendor has not defined POSIX macro F_GETFL, used at C:/Perl/site/ +lib/Net/HTTPServer.pm line 1091
I have looked at the doc's for the POSIX module on my system and it would appear that the constant is defined. What is going on? Here is the code from within HTTPServer:
Many thanks...###################################################################### +######### # # _nonblock - given a socket, make it non-blocking # ###################################################################### +######### sub _nonblock { my $self = shift; my $socket = shift; my $flags = fcntl($socket, F_GETFL, 0) or croak("Can't get flags for socket: $!\n"); fcntl($socket, F_SETFL, $flags | O_NONBLOCK) or croak("Can't make socket nonblocking: $!\n"); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Advice on HTTPServer problem please
by fmerges (Chaplain) on Jun 28, 2005 at 20:47 UTC | |
by jdtoronto (Prior) on Jun 28, 2005 at 21:49 UTC | |
|
Re: Advice on HTTPServer problem please
by jdtoronto (Prior) on Jun 29, 2005 at 16:01 UTC |