Net::Server is not officially supported on Win32, and it's not listed on CPAN as having passed the tests on Win32. However, the only trouble I had getting it to install under ActiveState Perl was that it used alarm in its test suite. Everything else about the tests appeared to work fine, so I installed it using -force.

So far, everything seems to be working fine, except for two things. I come to the monks now hoping that someone can at least point me in the direction to solving these two issues. Note that both of these problems go away if I run the code under cygwin, or if I use Net::Server::Simple instead of Net::Server::Fork, but there are a few things I want to do that require forking and ActivePerl (specifically, a systray icon and consolessness).

Firstly, it will accept multiple concurrent connections just fine, but the sockets on the second and later concurrent connections don't close when I return from my process_request handler. They don't close until I shut down the server. For my specific application, this will not be an issue but I'm still curious.

Secondly, my program crashes strangely if I try to use a regexp with capturing parens in it. This only happens, however, while processing the next client to connect after the first has disconnected. Multiple clients can connect while the first is still connected and be processed normally (though they then run into the first problem I mentioned). Note, again, that it only occurs when I use the forking personality of Net::Server.

I've include a short piece of code below that demonstrates the problem(s). To test it, run the code, then telnet to the port it reports twice in a row. (ie:

C:\> telnet localhost 20203 C:\> telnet localhost 20203
)

I'm probably going to try converting the test case over to a handle the sockets and forking manually (ie, remove Net::Server) to see if the problem is there or somewhere in Net::Server. Please, any ideas or suggestions on where else to look, or another approach to try, are welcome!

Sample code:

#!/usr/bin/winperl use warnings; use strict; use base 'Net::Server'; sub process_request { print "Hello.\r\n"; warn "Foo.\n"; # This line causes an error dialog to pop up with the # following message under Win2k: # The instruction at "0x28073fc9" referenced memory at "0x01fc2da0 +". # The memory could not be "read". "string" =~ /(.)/; warn "Got $1\n"; sleep 10; print "Goodbye.\r\n"; } # Auto-flush STDOUT and STDERR my $old = select(STDOUT); $|=1; select(STDERR); $|=1; select($old); # Start the server main->run();

Perl version:

This is perl, v5.6.1 built for MSWin32-x86-multi-thread
(with 1 registered patch, see perl -V for more detail)

Copyright 1987-2001, Larry Wall

Binary build 633 provided by ActiveState Corp. http://www.ActiveState.com
Built 21:33:05 Jun 17 2002

bbfu
Black flowers blossom
Fearless on my breath

update (broquaint): added <readmore>


In reply to Net::Server::Fork on Win32: Memory access error on pattern match by bbfu

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.