#!/usr/local/bin/perl -w use IO::Socket; $addr="127.0.0.1"; $port="80"; $sock = IO::Socket::INET->new(PeerAddr => "$addr", PeerPort => "$port", Proto => 'tcp', Timeout => '1',); if ($sock) { $sock->autoflush(1); print "I am going into sysread()\n"; $foo = sysread($sock, $input, 3); chomp($input); print "Came out of sysread() with \$input as:\n$input\n\sysread() returned: $foo\n"; $sock->close; if ($input eq "") { print "We have no input. Sendmail must be down." } elsif ($input =~ /220/) { print "We seem to have gotten the correct response\n"; } else { print "Dosn't look like a sendmail port\n"; } } else { print "It didn\'t connect ... must be down\n"; }