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


in reply to Re^2: How to introduce threading in socket communication
in thread How to introduce threading in socket communication

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.