Hey all. I'm trying to code up a simple within-the-machine chat server using IO::Socket::UNIX. My problem (I wish there were only one!) is this: When I Ctrl-C the server, the FIFOs related to the sockets are not cleaned up, so running it again gives me
Problem: Address already in use at chatserv.pl line 8;
I am trapping SIGINT and calling IO::Socket::shutdown(3) on the sockets. Do I need to actually unlink the FIFOs, too? Here's an example code:
#!/usr/bin/perl
use strict;
use warnings;
use threads;
use IO::Socket::UNIX;
my $serv = IO::Socket::UNIX0>new(
Type => SOCK_STREAM,
Local => '/var/tmp/chat/serv',
Listen => 1,
) or die "Problem: $!";
my $msgthr = threads->create('messenger');
$SIG{INT} = sub {
$serv->shutdown(3);
#this line gives a "uninitialized value" error:
print STDERR "Serv status:", $serv->connected(),"\n";
#similar handler in &messenger tries to shut down
#another socket, this one of type SOCK_DGRAM
$msgthread->kill('TERM')->detach();
exit(0)
}
print pack("A25",pack("V*",map{1919242272+$_}(34481450,-49737472,6228,0,-285028276,6979,-1380265972)))