I really need immediate help with is TCP communication between a master app and a slave app. As a base upon which to build I would like to set up a script on one box that throws a message, any message, through any port to a script on another box. The second script should loop until message is received, then print and die.
(Please excuse - I deleted the orginal post.)
Linux boxes are cheap. Get one which will act as a "listener" and run several listening deamons. Reasoning -
Many of the modules you will wish to use may not be available or work incorrectly under Windows 2k/XP. While these systems are likely to house the running applications which will throw the data to a central lister - it is not required that the listener be localized on the same system - if it were there are better methods of data collection.
Since you specifically requested TCP throwing and catching allow me to get you off on the right foot -
(See comp.lang.perl.moderated for a more complete example.)
use strict; use Net::PcapUtils; use NetPacket::Ethernet qw(:strip); use NetPacket::IP qw(:strip); use NetPacket::TCP;
# This is a generic "catcher" - modify to taste. # Writing a data "thrower" is left upto you.
sub process_pkt { my($arg, $hdr, $pkt) = @_;
my $tcp_obj = NetPacket::TCP->decode(ip_strip(eth_strip($pkt)));
if (($tcp_obj->{src_port} == 2525) or ($tcp_obj->{dest_port} == 2525)) { print($tcp_obj->{data}); } }
Net::PcapUtils::loop(\&process_pkt, FILTER => 'tcp');
# 'I' loop eternally waiting for someone to throw data at me...
__END__
You will find a very good discussion (alot at a easy to follow beginning level) of TCP and such in "Network Programming with Perl"
Perl is alot like Fortran in that complex things can be easily represented.
-Sx-
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>