coontie has asked for the wisdom of the Perl Monks concerning the following question:

Here's my problem. I want to have a routine that sniffs UDP traffic and creates a button every time it detects a certain pattern. I've the routine written already, it blocks (a consequence of the multicast implementation) until a packet for that multicast address is received. The problem is tying this to the MainLoop of Tcl. I've basically two loops: 1 for the multicast sniffing and 1 for the mainLoop. How can I set this up? I tried multithreading this but I can't make the mainWindow object shareable amongst the threads. This doesn't work:
my $mainWindow = MainWindow->new; share ($mainWindow); Error: Invalid value for shared scalar at /usr/lib/perl5/site_perl/5.8.5/i386 +-linux-thread-multi/Tk/Widget.pm
What to do?

Replies are listed 'Best First'.
Re: threads and Tcl or how to do multiple loops
by zentara (Cardinal) on Dec 13, 2005 at 22:43 UTC
    Something like this is what you are after-> Tk-with-worker-threads. You can also check out the threads example in the latest Gtk2-perl module, it has better thread support.

    I'm not really a human, but I play one on earth. flash japh
Re: threads and Tcl or how to do multiple loops
by choedebeck (Beadle) on Dec 13, 2005 at 21:26 UTC
    Perl/Tk is not thread safe. If you are looking to execute a non-blocking command there is a way. Take a look at Tk::after.
Re: threads and Tcl or how to do multiple loops
by renodino (Curate) on Dec 13, 2005 at 21:29 UTC
    Plug "tk threads" into the Search box. You'll get lots of hits...