Yesterday, Steve Schein wrote: > Launch the TCP socket and both UDP sockets on threads spawned from the > main program and keeping them open to perform on-going tasks which > primarily includes passing data back to the main program for two of the > sockets and sending messages from the main program for the other > socket. I suspect the sockets need to stay open and not necessarily the > threads but I hope to learn that during through the dialog here. I've > read through perlthrtut a couple of times and walked away with an empty > and uneasy feeling. In that document a reader is told that a thread > must be closed before data can be passed back which seemed like a bad > thing considering my sockets are intended to stay open indefinitely.
You may want to reread perlthrtut. It says that a thread can return data just like any subroutine could when it ends. But a lot of the reason to use threads it to be able to pass data from thread to thread easily. That's what shared variables are all about. Set a variable to a value (lock it first) in one thread, and read the value (again, lock it first) in another thread. Or use Thread::Enqueue, and enqueue a value in one thread, then dequeue it in another. Paul
