Hello,
We have hit what looks like a bug in the activestate (build 623)
implementation of the windows socket IO.
What we are doing is writing a server will accept incoming requests on a
port and spawn in the same thread a client socket to handle the request.
The client socket returns an appropriate data buffer then closes down.
The problem is that after about 40 client sockets have been created and
shut down an error message about "unable to print on closed file handle" is
generated. It appears that for each client/server request at least one
file handle is not being closed, and as a result windows eventually reaches
a limit on open file handles and the process dies.
We have written a simple test script below that simulates the problem and
generates this error. Has anyone had any experience of this problem
before, or any suggestions on a work around??
Thanks in advance
Richard Blakers
//---------------code follows---------------------------------
#!/usr/bin/perl -w
use strict;
use IO::File;
use IO::Handle;
use Socket;
my $i;
my @fh=();
socket(Server, PF_INET, SOCK_STREAM, getprotobyname('tcp'))
or die("socket [$!].\n");
setsockopt(Server, SOL_SOCKET, SO_REUSEADDR, pack("l",1))
or die("setsockopt [$!].\n");
bind(Server, sockaddr_in(1234, INADDR_ANY)) or die("bind [$!].\n");
listen(Server, SOMAXCONN);
my $client=new IO::Handle;
defined($client) or die("new IO::Handle [$!].\n");
# loop creating clients to handle a request - fails after about 40 iterations
for ($i=0; $i<1000000; $i++)
{
my $f=accept($client,Server);
unless (defined($client) and ref($client) =~ "IO::")
{
print "opened [$i] then fail because [$!] or [$^E].\n";
defined($client) and print("client=",ref($client),"\n");
exit 0;
}
print $client "Hello [$i].\n";
flush $client;
shutdown($client,2);
defined($client) and $client->close();
# push(@fh,$f);
}
//----------------end of code -----------------------------
Ecobyte Pty Ltd
PO Box 565
Bega NSW Australia 2550
Ph (61) 02 6494 1729
FAX (61) 02 6494 1729
Email [EMAIL PROTECTED]
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/activeperl