Esteemed monks,

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 ]; }
I then try to connect to the appropriate URL (according to the doc's it is: http://drkwolfca.dnsalias.org:6789/foo/bar.pl?test=bing ) and I get the following on the console at the server end:
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
and we are back to prompt.

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:

###################################################################### +######### # # _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"); }
Many thanks...
jdtoronto

In reply to Advice on HTTPServer problem please by jdtoronto

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.