in reply to Re: Two TCP Connections, one script
in thread Two TCP Connections, one script
port 12345 will only receive the telemetry in XML format and port 6789 will only send the waypoint XML file. My question would be how can I separate these processes?#! perl -slw use strict; use threads; use Thread::Queue; use IO::Socket; my $Q = new Thread::Queue; my @threads = map async { while( 1 ) { my $s = IO::Socket::INET->new( $_ ) or die $!; while( my $input = <$s> ) { $Q->enqueue( $input ); } sleep 5; } }, 'localhost:12345', 'localhost:6789'; while( my $input = $Q->dequeue ) { chomp $input; if( $input =~ m[Z:] ) { ## Deal with telemetry print "Got telemetry: '$input'"; } else { ## Deal with waypoint; print "Got waypoint: '$input'"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Two TCP Connections, one script
by BrowserUk (Patriarch) on Apr 05, 2008 at 03:52 UTC | |
by deadpickle (Pilgrim) on Apr 05, 2008 at 06:09 UTC | |
by BrowserUk (Patriarch) on Apr 05, 2008 at 13:42 UTC |