may be sth like this will work?!

#!/usr/bin/perl

use IO::Select;
use IO::Socket::INET;

use ResourcePool;
use ResourcePool::Factory::DBI;
use ResourcePool::Command::DBI::Execute;


# Initialize parameter ------------------------------------------------

$debug= 1;
$main = new IO::Socket::INET (
      LocalHost => '127.0.0.1',
      LocalPort => 6000,
      Listen => 5,
      Proto => 'tcp',
      Reuse => 1 ) || die $!;
$zero = chr(0);
$/ = $zero;
$\ = $zero;
$| = 1;
my $dsn = "DBI:mysql:DBNAME;your.server#2;3306";
my $username = "xxx";
my $passwd = "zzz";

# Initialize Ressource ------------------------------------------------

my $factory = ResourcePool::Factory::DBI->new(
      $dsn,
      $username,
      $passwd);
my $pool = ResourcePool->new($factory, MaxTry => 3);


# Initialize IO::Select ------------------------------------------------

$handles = new IO::Select();
$handles->add($main);

print "Starting listening cycle\n" if($debug > 0);

LISTEN: while (1)
   {
      ($pending) = IO::Select->select($handles, undef, undef, 60);
      foreach $sock (@$pending)
      {
         if ($sock == $main)
         {
            $num++;             print "Got new connection: $num from ".$sock->sockhost()."\n" if($debug > 0);
            my $newsock = $sock->accept();
            $newsock->autoflush();
            $number{$newsock} = $num;
            $handles->add($newsock);
         } else {
            my $buf = <$sock>;
            if ($buf)
            {
               print "Existing socket $number{$sock} is pending: " if($debug > 0);
               chomp $buf;
               print "$buf\n" if($debug > 0);
               my $cmd = ResourcePool::Command::DBI::Execute->new();
               $pool->execute($cmd, $buf);
            } else {
               print "Socket $number{$sock} is gone.\n" if($debug > 0);
               $handles->remove($sock);
            }
         }
      }
   }


In reply to Re: how can N client.pl connect to one deamon serving mysql by saxman25
in thread how can N client.pl connect to one deamon serving mysql by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.