[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

ARP Ping and ICMP in Ruby?

Ruby Rubyruby

8/10/2007 2:42:00 PM

What would I have to do in order to be able to send an ARP Ping or a
regular ICMP_ECHO_REQUEST in Ruby? Is it possible?
--
Posted via http://www.ruby-....

4 Answers

Klodus Klodus

8/10/2007 10:20:00 PM

0

Ruby Rubyruby wrote:
> What would I have to do in order to be able to send an ARP Ping or a
> regular ICMP_ECHO_REQUEST in Ruby? Is it possible?

require 'ping'

Ping.pingecho('example.com')

or

system('ping -c1 www.example.com')

--
Posted via http://www.ruby-....

Konrad Meyer

8/10/2007 11:03:00 PM

0

On Friday 10 August 2007 03:20:19 pm Klodus Klodus wrote:
> Ruby Rubyruby wrote:
> > What would I have to do in order to be able to send an ARP Ping or a
> > regular ICMP_ECHO_REQUEST in Ruby? Is it possible?
>
> require 'ping'
>
> Ping.pingecho('example.com')

Unfortunately, this isn't a 'ICMP_ECHO_REQUEST', it's an attempt to connect
to the remote machine on the 'echo' port. If the connection is refused or
allowed, pingecho() returns true. If it times out, or otherwise errors,
it returns false. Either way, it's not ICMP if you *need* ICMP.

> or
>
> system('ping -c1 www.example.com')

Shelling out to a ping command is probably a bad idea for portability
reasons.

If a TCP connection test works for you then go with the stdlib Ping library.
If it doesn't, you might look into RubyInline or writing a simple C
extension for basic ICMP requests.

Cheers!
--
Konrad Meyer <konrad@tylerc.org> http://konrad.sobertil...

Gordon Thiesfeld

8/10/2007 11:51:00 PM

0

On Aug 10, 6:02 pm, Konrad Meyer <kon...@tylerc.org> wrote:
> On Friday 10 August 2007 03:20:19 pm Klodus Klodus wrote:
>
> > Ruby Rubyruby wrote:
> > > What would I have to do in order to be able to send an ARP Ping or a
> > > regular ICMP_ECHO_REQUEST in Ruby? Is it possible?


http://raa.ruby-lang.org/project...

hope it helps

Gordon

Daniel Berger

8/11/2007 5:17:00 AM

0



On Aug 10, 8:42 am, Ruby Rubyruby <netwer...@yahoo.com> wrote:
> What would I have to do in order to be able to send an ARP Ping or a
> regular ICMP_ECHO_REQUEST in Ruby? Is it possible?

require 'net/ping'
include Net

icmp = Ping::ICMP.new('foo.com')

if icmp.ping?
# Successful
else
# Failed
end

gem install net-ping

Regards,

Dan