Thanks guys,
I have the following and its working great:
#!/usr/bin/perl -w
my $socket;
my $port = 7777;
my $host;
use IO::Socket;
use Sys::Hostname;
$SIG{CHLD} = sub {wait ()};
$host = hostname();
# START LOOP HERE
my $main_sock = new IO::Socket::INET (LocalHost => $host,
LocalPort => $port,
Listen => 5,
Proto => 'tcp',
Reuse => 1,
);
if (!$main_sock)
{
die "Socket could not be created. Reason: $!\n";
}
my $buf;
my $new_sock;
my $pid;
while ($new_sock = $main_sock->accept()) {
$pid = fork();
if ($pid == 0) {
# Child process
while (defined ($buf = <$new_sock>))
{
# do something with $buf ....
my @lines = split(/\|/,$buf);
exit(0); # Child process exits when it is done.
}
} # else 'tis the parent process, which goes back to accept()
}
close ($main_sock);
exit;
However how do i save the data recieved to a log file? say /usr/home/l
+og.txt
|