I need the Telnet session below available to 3 threads(connect, disconnect, & scan).

What is the purpose of sharing one session between 3 threads?

The reasoning behind my question:

  1. If 3 threads (or processes; this isn't a "threads flaw") try to communicate via a single session concurrently:

    then their communications will all interfere with each other and the remote session will just become corrupted and fail.

  2. If the idea is to interlock the session so that only one of the threads can communicate at any given time and doesn't unlock the session to the other threads until it has completed its transactions:

    Then it make no sense to share the telnet session; you'd just be making life hard for yourself.

    Far better to start a fourth thread that has a input queue.

    Have the three threads queue the information required to perform their requests; the fourth thread issues the request via its single, unshared telnet session; and then return the results to the calling thread.

    The serialisation is automatic and efficient; and you avoid all the complications and risks of sharing a complex object.

That said; telnet servers are designed to host multiple sessions. The simplest solution would be to have each of your threads starts its own unshared session to the remote telnet server and let it do what it is designed to do.

If you have a reason not covered by the above for wanting to share a single telnet session; please identify it.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
In the absence of evidence, opinion is indistinguishable from prejudice.
I'm with torvalds on this Agile (and TDD) debunked I told'em LLVM was the way to go. But did they listen!

In reply to Re: How do you share an object(Telnet Session) between threads? by BrowserUk
in thread How do you share an object(Telnet Session) between threads? by jmlynesjr

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.