in reply to Re: [threads] Sharing object through threads
in thread [threads] Sharing object through threads
since you had the similar problem couple a years ago i was wondering if you found the solution or.... (sharing globs)#!/usr/bin/perl -w use strict; use IO::Socket; use threads; use threads::shared; my $server = IO::Socket::INET->new( Proto => 'tcp', LocalPort => $ARGV[0], Listen => SOMAXCONN, Reuse => 1); die "can't setup server" unless $server; share(my @jobs); while (my $client = $server->accept()) { $client->autoflush(1); print "[Connect from ". $client->peerhost . ":" . $client->peerpo +rt . "]\n" ; # clients address my $thr = threads->new(sub { push(@jobs,share($client)); ### NOTE THIS IS UNS +HARABLE ### while (<$client>) { if (/test/i){ print $client "looks good, @jobs\n"; } elsif (/quit/i){ print $client "bye\n"; last; } } # finishe while } )->detach; close $client; }
thank you
so the idea is when one client talks server listens and shares its responses with all connected clients
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: [threads] Sharing object through threads
by BrowserUk (Patriarch) on Nov 17, 2009 at 19:27 UTC | |
Re^3: [threads] Sharing object through threads
by ikegami (Patriarch) on Nov 17, 2009 at 19:58 UTC | |
by BrowserUk (Patriarch) on Nov 17, 2009 at 20:46 UTC | |
by ikegami (Patriarch) on Nov 17, 2009 at 22:13 UTC | |
by BrowserUk (Patriarch) on Nov 17, 2009 at 22:22 UTC | |
by ikegami (Patriarch) on Nov 17, 2009 at 22:30 UTC |