hi guys i have created a script because i want a listbox and inside of them i want visualize a stream data , i understand for do that is necessary use threads first create a stream and second manages a Tk the problem is in Tk listbox appear only one time a data stream why ??, if anyone have some idea is welcome thanks at all
this is a my code (perl 5 strawbaerry in windows 10 64bit ) use threads; use threads::shared; use Perl::Tidy; use Tk; use Tk::LabFrame; use Tk::ROText; use strict; use IO::Socket::INET; my $x:shared=1; my $data :shared; my @workerThreads; my @otherThreads; push @workerThreads , threads->create (\&threadSub1) for (1..10); push @otherThreads , threads->create (\&threadSub2) ; $_->join() for @workerThreads ; $_->join() for @otherThreads ; print("$x\n"); sub threadSub2 { my $mw = MainWindow->new ; $mw->geometry( "600x600" ); my $lbox = $mw->Listbox(-height =>500, -width =>500)->pack(); $lbox->insert('end', $data ); MainLoop; } sub threadSub1 { # auto-flush on socket $| = 1; # creating a listening socket my $socket = new IO::Socket::INET ( LocalHost => '127.0.0.1', LocalPort => '23456', Proto => 'tcp', Listen => 5, Reuse => 1 ); die "cannot create socket $!\n" unless $socket; print "server waiting for client connection on port 23456 \n"; while(1) { # waiting for a new client connection my $client_socket = $socket->accept(); # get information about a newly connected client my $client_address = $client_socket->peerhost(); my $client_port = $client_socket->peerport(); print "connection from $client_address:$client_port\n"; # read up to 1024 characters from the connected client #my $data = ""; $client_socket->recv($data, 1024); print "received data: $data\n"; my @data_array = split(/;/,$data); foreach (@data_array) { return "$_\n"; print "$_\n"; } # write response data to the connected client $data = "ok"; $client_socket->send($data); # notify client that response has been sent shutdown($client_socket, 1); } $socket->close(); }