bbfu has asked for the wisdom of the Perl Monks concerning the following question:
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>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Net::Server::Fork on Win32: Memory access error on pattern match
by Jenda (Abbot) on Apr 08, 2003 at 12:48 UTC | |
by bbfu (Curate) on Apr 08, 2003 at 19:33 UTC |