• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 139
  • Last Modified:

Sockets

Hi
I need a code to connect to a apache server and check if
it is runing.

Thanks
0
odnanref
Asked:
odnanref
1 Solution
 
bebonhamCommented:
can you use lwp instead of sockets, it has more overhead, but I can show you how to do it :)
0
 
marecsCommented:
This should do the trick. Taken from
perldoc perlipc

use IO::Socket;
$host = 'www.yourserver.com';
$port = 80;
$EOL = "\015\012";
$BLANK = $EOL x 2;
$remote = IO::Socket::INET->new( Proto     => "tcp",
                                 PeerAddr  => $host,
                                 PeerPort  => $port,
                               ) or die $!; # This is probably enough of a check if the server is up.
$remote->autoflush(1);
print $remote "HEAD / HTTP/1.0" . $BLANK; # Could also be GET
while ( <$remote> ) { print }
close $remote;
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now