i might be missing a point in the question
anyway, the following program worked by
me. a tricky thing was that the $client in
the while loop had to go out of scope so
the socket could really have been closed.
if i declared it before the while loop
it seemed to lock somehow, anyway, there
was no way to close it then. i reorganized
my code then and put the $client variable
into the while loop block, when it lost the scope
in while and the client thread said $client->close();
it really closed itself up.
Martin
my program looks like this :
#!/usr/bin/perl
use strict;
# do we still need this ?
use Socket;
use threads;
use threads::shared;
use logger;
use IO::Socket;
$| = 1;
my $EOL = "\015\012";
my $proto = "tcp";
my $port = 15300;
debug("Trying to bind a socket");
my ($server);
$server = IO::Socket::INET->new (Listen => SOMAXCONN,
LocalPort => $port,
Proto => 'tcp',
Blocking => 0,
Reuse => 1);
die "can't setup server" unless $server;
debug("waiting for connection");
while ( 1 > 0) {
my $client = $server->accept();
debug("spooky, we got a client from
(".$client->peerhost().":".$client->peerport().")");
threads->create(\&handler,$client);
debug("waiting for another connection");
}
debug("all done");
sub handler() {
my $client;
$client = pop @_;
$client->autoflush(1);
print $client "Hello Hello $EOL";
$client->close();
debug("handled a client");
}