Hi, I'm trying to write to all threads on a multi-threaded INET server. I basically have it going, but I've run into a situation where I'm trying to extract the $client name from a reference, and can't seem to find the way. Now I'm wondering if it's even possible. The code is long, and rather than waste disk space, I will just show the basic code and the Dumper outputs.

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' ) ];

In reply to dereferencing IO::Socket::INET from a thread by zentara

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.