#!/usr/bin/perl -w use strict; use IO::Socket; use IO::File; use Switch; use Data::Dumper; my $peerAddr; # that's the hosts ip-adress my $peerPort; # that's the hosts port # the usage is: command ip-addr port if ($ARGV[0] && $ARGV[1]) { $peerAddr = $ARGV[0]; $peerPort = $ARGV[1]; } else { die "Usage: $0 target-address portnumber\n"; } # CREATING THE SOCKET my $server = new IO::Socket::INET ( PeerAddr => $peerAddr, PeerPort => $peerPort, Proto => "tcp", Type => SOCK_STREAM ) or die "*** Can't connect to server. ($!) ***\n"; my $maxBuffer = 1024; my $myName; # CREATING THE FORK my $pid = fork();                  # the fork lets us create two parallel processes if ($pid == 0) { # when our process is active -> do something main("start",""); } else { # otherwise -> read out the server's messages while(1) { my $nval = $server->recv(my $data, $maxBuffer, 0); if (defined($nval) && length($data)) { XMLparse($data); } } } $server->close(); exit;