Goodday. I'm doing socketprogramming, trying to communicate with f.e. smtp,pop,ftp servers. Now i'm trying to ping a host, but don't know how to start. I've added some code i use to communicate to a smtp-server, to give an idea of what i had in mind.
use IO::Socket;
$ip = 'latte.isprime.com';
$sock = IO::Socket::INET->new(PeerAddr => $ip,
PeerPort => 587,
Proto => 'tcp',
Timeout => 1,
Type=>SOCK_STREAM);
if($@) { print "$_ Failed\n"; }
else{
$sock->recv($ant,1024,0);
print $ant;
}
$groet = "EHLO latte.isprime.com\n";
print $groet;
print $sock $groet;
$sock->recv($ant,1024,0);
print $ant;
$afz = 'MAIL FROM:<ayfi@live.nl>'."\n";
print $afz;
print $sock $afz;
$sock->recv($ant,1024,0);
print $ant;
My first problem is that i have no port to connect to. I've had a look at the Net::Ping.pm file and i can see sockets are used, but i can't just work my way through it.
Can someone show me how to ping a host in this manner? Or can point me in the right direction? Thank you
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.