thanx to saxman!
i modified the
deamon.pl to:
#!/usr/bin/perl -w
use strict;
use warnings;
use IO::Socket;
use ResourcePool;
use ResourcePool::Factory::DBI;
use ResourcePool::Command::DBI::Execute;
# Initialize parameter ------------------------------------------------
my $port = 6000;
my $dsn = "DBI:mysql:
DBname;
DBserver;3306";
my $username = "xxx";
my $passwd = "yyy";
# Initialize Ressource ------------------------------------------------
my $factory = ResourcePool::Factory::DBI->new(
$dsn,
$username,
$passwd);
my $pool = ResourcePool->new($factory, MaxTry => 3);
# Initialize Socket ------------------------------------------------
my $sock = new IO::Socket::INET(
LocalHost => 'localhost',
LocalPort => $port,
Proto => 'tcp',
Listen => SOMAXCONN,
Reuse => 1);
$sock or die "no socket :$!";
my($new_sock, $c_addr, $buf);
while(1==1)
{
while (($new_sock, $c_addr) = $sock->accept())
{
my ($client_port, $c_ip) =sockaddr_in($c_addr);
my $client_ipnum = inet_ntoa($c_ip);
my $client_host =gethostbyaddr($c_ip, AF_INET);
my $code = '';
while (defined ($buf = <$new_sock>))
{
$code .= $buf;
}
my $cmd = ResourcePool::Command::DBI::Execute->new();
$pool->execute($cmd, $code);
}
}
exit;
__END__
Also i used a skript which forked 100 instances of the
client.pl each pushing a ~7k INSERT statement to the
deamon.pl; this worked fine - all 7000 entries arrived at the DB server and were processed.
it took around 5 secs for the database to execute all statements. that brought me to the following problem:
if there are a lot of client scripts running, the queue will fill up and the clients will keep waiting for the deamon if its queue is full. so the traffic-problem i tried to solve just shiftet to a local connection bottleneck... :-(
is there a possibility to do the socket stuff multithreaded?? each thread with its own socket but using the same sql-queue???