Can't locate auto/threads/is_joinable.al in @INC (@INC contains: /etc/perl /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi /usr/lib64/perl5/vendor_perl/5.8.8 /usr/lib64/perl5/vendor_perl /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi /usr/lib64/perl5/site_perl/5.8.8 /usr/lib64/perl5/site_perl /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi /usr/lib64/perl5/5.8.8 /usr/local/lib/site_perl .) at ./OEFS.pl line 32
####
#!/usr/bin/perl
use strict;
use IO::Socket::UNIX;
use threads;
use threads::shared;
my $LSocket;
my @Links;
my $NumConnections = 32; #allow for 32 connections
my @Connections = (1 .. $NumConnections);
my @StructDs : shared;
my @StoreDs : shared;
sub ConThread($);
MAIN:
{
die("The first and only requirement should be the name for this OEFS instance, and is required!\n") if (!($ARGV[0]));
#Start the listener
mkdir("/tmp/OEFS/") if (!(-e "/tmp/OEFS"));
unlink('/tmp/OEFS/' . $ARGV[0]);
$LSocket = new IO::Socket::UNIX('Listen' => 1, 'Local' => '/tmp/OEFS/' . $ARGV[0]);
die("$!\nUnable to create listen socket!\n") if (!($LSocket));
my $Link;
my $IDX;
print("Listening...\n");
while ($Link = $LSocket->accept())
{
#Clean out old threads
foreach my $I (1 .. $NumConnections)
{
if (($Links[$I]) && ($Links[$I]->is_joinable()))
{
$Links[$I]->join();
unshift(@Connections, $I);
print("Connection #$I now free\n");
}
}
print("Incomming Connection\n");
$IDX = pop(@Connections);
if ($IDX)
{
print("Using connection #$IDX\n");
print("Spawning Thread\n");
#New thread.
$Links[$IDX] = threads->create(\&ConThread, $Link);
}
else
{
print("Too many connections\n");
print $Link "Maximum number of connections has been reached.\n";
$Link->close();
}
}
}
sub ConThread($)
{
my ($Socket) = @_;
print $Socket "Ready\n";
$Socket->close();
return;
}
####
#!/usr/bin/perl
use strict;
use IO::Socket::UNIX;
my $TheSocket;
MAIN:
{
die("The first and only requirement should be the name of the OEFS instance, and is required!\n") if (!($ARGV[0]));
$TheSocket = new IO::Socket::UNIX('Peer' => '/tmp/OEFS/' . $ARGV[0]) || die("$!\nUnable to connect!");
print "Socket says: " . <$TheSocket> . "\n";
$TheSocket->close();
exit(0);
}