zentara has asked for the wisdom of the Perl Monks concerning the following question:
I'm creating 3 threads each with a socket connection. When I save the $clients in @clients, I can loop thru the @clients array and print to each $client. But when I try to save $thr to @thrs, I cannot get the $client back out to print to it. I can get the thread's tid, but that's it.
So my question is this:
Can I get the thread's $client name from the information provided in the Dump of @thrs? For instance, I can loop through @clients and print to each thread. But how do I convert the @thrs to usable $client names in order to print to it?
for(1..3){ $client = $listener->accept; my $thr = threads->create(\&start_thread, $client, ++$client_ +num); push(@clients,$client); push(@thrs,$thr); print 'Dump of @clients-> ',Dumper([@clients]),"\n"; print 'Dump of @thrs-> ',Dumper([@thrs]),"\n"; } ############################################## Dump of @clients-> $VAR1 = [ bless( \*Symbol::GEN1, 'IO::Socket::INET' ), bless( \*Symbol::GEN2, 'IO::Socket::INET' ), bless( \*Symbol::GEN3, 'IO::Socket::INET' ) ]; Dump of @thrs-> $VAR1 = [ bless( do{\(my $o = '137520752')}, 'threads' ), bless( do{\(my $o = '138536664')}, 'threads' ), bless( do{\(my $o = '138556504')}, 'threads' ) ];
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: dereferencing IO::Socket::INET from a thread
by bschmer (Friar) on Nov 21, 2003 at 16:20 UTC | |
by zentara (Cardinal) on Nov 21, 2003 at 16:40 UTC |