Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: How to introduce threading in socket communication

by BrowserUk (Pope)
on Oct 03, 2013 at 14:22 UTC ( #1056763=note: print w/ replies, xml ) Need Help??


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
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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1056763]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (8)
As of 2014-10-24 23:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (138 votes), past polls