http://www.perlmonks.org?node_id=1056763


in reply to How to introduce threading in socket communication

Without looking at the details too closely, your server already appears to support concurrent clients via IO::Select.

What are you hoping to gain by adding threading to the mix?


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".
In the absence of evidence, opinion is indistinguishable from prejudice.
  • Comment on Re: How to introduce threading in socket communication

Replies are listed 'Best First'.
Re^2: How to introduce threading in socket communication
by Anonymous Monk on Oct 03, 2013 at 14:35 UTC

    The data received by the server will be send to a Tk gui to update some gui row. The gui will have 50k of row of HList widget and some 20k of those row will be simultaneously changing. Without thread the gui is hanging and not scrollable and usable. Hence trying to introduce thread so that the gui does not hang and stays unaffected when thousands of its rows are changing itself.

      Without thread the gui is hanging and not scrollable and usable. Hence trying to introduce thread so that the gui does not hang ...

      Then why does the OP talk of "But now I want this to be done in a 2-threaded mechanism, where every new connection should start a new thread to accept the data."? (Besides that saying "a 2-threaded mechanism" and "every new connection should start a thread" in the same sentence is very confused; and that the OP code showing nothing to do with Tk.)

      You have a concurrent server which could be wrapped up into a function.

      1. Start a thread and run that function in it.
      2. Create a Thread::Queue and have the server thread post the received data onto it.
      3. Run the gui in the main thread and start a periodic timer that checks the queue (say) every 10th of a second, dequeues what it finds and adds it to your gui.

      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".
      In the absence of evidence, opinion is indistinguishable from prejudice.

        Am fairly new to perl.
        Can you please show me a workng example