You cannot share socket among threads, not becaue it is a socket. The real problem is that it is an object.

In Perl 5.8.0, sharing object among threads is absolutely unsafe, as bless is not thread-safe / not implemented for threading (in 5.8.0). This is stated in document for threads::shared.

Socket can be used on thread, that's not a problem, but can not be shared among threads.

This is something they are working on, so your concept would work with future versions of Perl with no problem.

Update

jasonk, I have read your reply:
  1. What I stated in this post is conceptually correct. Let me repeat it: as for Perl 5.8.0, object can not be shared among threads. In future versions, after bless is fixed for multi-threading, socket could be shared among threads, with no difference from sharing other object.
  2. Don't jump to the conclusion that Anonymous Monk's concept in his mind is wrong, just because his code has some bugs.
  3. What you said about his code is not quite right, and I replied you with a detailed analysis.

In reply to Re: sharing variables with threads by pg
in thread sharing variables with threads 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.