Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

pinging a remote machine

by Anonymous Monk
on Jul 29, 2013 at 10:02 UTC ( #1046821=perlquestion: print w/replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

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

Replies are listed 'Best First'.
Re: pinging a remote machine
by Anonymous Monk on Jul 29, 2013 at 10:08 UTC

    Can someone show me how to ping a host in this manner

    Why?

    Or can point me in the right direction? Thank you

    Why can't you use Net::Ping ?

Re: pinging a remote machine
by McA (Priest) on Jul 29, 2013 at 10:08 UTC

    Hi,

    what is wrong with Net::Ping?

    Best regards
    McA

Re: pinging a remote machine
by Anonymous Monk on Jul 29, 2013 at 10:30 UTC

    nothing wrong.

      I'm just asking, because your question makes me feel that there are other questions to be answered before you start a perl implementation on your own.

      You wrote:

      My first problem is that i have no port to connect to.

      Do you mean a ICMP-ping or a UDP-ping? Answering this question will bring you a step further.

      Another option for you is: Ask a more specific question concerning a part of Net::Ping's sources you don't understand. I'm sure, Monks will help you.

      Best regards
      McA

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1046821]
Front-paged by Arunbear
help
Chatterbox?
[choroba]: 3 PM in Vietnam, BTW
Discipulus maybe a wrong impression..
[karlgoethebier]: Discipulus: Workshops are for weenies ;-)
[Discipulus]: here 43C high umidity, tiger mosquitos, violence in the street.. everywhere is vietnam
[karlgoethebier]: OK, i'm socially unacceptable
[karlgoethebier]: Discipulus: Were the hell are you today?
[Discipulus]: ..or suitable for the presidence ;=)
[Discipulus]: at Caput Mundi
[marto]: choroba, have you moved to Vietnam or just there for a while?

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (11)
As of 2017-06-27 08:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (600 votes). Check out past polls.