Net::PingExternal gives an errror

Hello there,

I'm having a problem with a tutorial to ping whatever.
I have snowleopard and both ruby's both give the same error:

uninitialized constant Net::PingExternal (NameError)

here is the code i'm using:

require 'rubygems'
require 'net/ping'
if Net::PingExternal.new('localhost').ping
  puts 'Localhost OK'
else
  puts 'Localhost NO respons'
end

i dont know what to do.
I cleaned en update macports
updated rubygems and rubygems1.9
reinstalled ruby 1.8.7 and ruby1.9

Some help woud be nice thx

···

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

# gem i net-ping

require 'rubygems'
require 'net/ping'
o = Net::Ping::TCP.new 'www.ccc.de', 80
o.ping? # => true

All the best, Sandor Szücs

···

On Sep 16, 2010, at 4:22 PM, Younes Baghor wrote:

Hello there,

I'm having a problem with a tutorial to ping whatever.
I have snowleopard and both ruby's both give the same error:

uninitialized constant Net::PingExternal (NameError)

here is the code i'm using:

require 'rubygems'
require 'net/ping'
if Net::PingExternal.new('localhost').ping
puts 'Localhost OK'
else
puts 'Localhost NO respons'
end

--

Try Net::Ping::External

Regards,

Dan

···

On Sep 16, 8:22 am, Younes Baghor <w3bwizart...@gmail.com> wrote:

Hello there,

I'm having a problem with a tutorial to ping whatever.
I have snowleopard and both ruby's both give the same error:

uninitialized constant Net::PingExternal (NameError)

thanks it works but its not correct i try them both:

if Net::Ping::TCP.new('loocaalhost')
  puts 'OK'
else
  puts 'NO respons'
end

if Net::Ping::External.new('loccalhost')
  puts 'OK'
else
  puts 'NO respons'
end

this is the output:
OK
OK
webwizartbe-iMac:balbaert younesbaghor$

2 times ok even when the localhost is spelled wrong.

someone know what the difference is between
Net::Ping::TCP.new('localhost')
Net::Ping::External.new('localhost')

thanks allot

···

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

thanks it works but its not correct i try them both:

if Net::Ping::TCP.new('loocaalhost')
puts 'OK'
else
puts 'NO respons'
end

if Net::Ping::External.new('loccalhost')
puts 'OK'
else
puts 'NO respons'
end

this is the output:
OK
OK
webwizartbe-iMac:balbaert younesbaghor$

2 times ok even when the localhost is spelled wrong.

You didn't call the ping? method in your example. You just called the
constructor.

someone know what the difference is between
Net::Ping::TCP.new('localhost')
Net::Ping::External.new('localhost')

The external ping uses your system's ping command. The TCP ping tries
to connect to the host via a Ruby TCPSocket.

Regards,

Dan

···

On Sep 16, 4:17 pm, Younes Baghor <w3bwizart...@gmail.com> wrote:

You didn't call the ping? method in your example. You just called the
constructor.

someone �know what the difference is between
Net::Ping::TCP.new('localhost')
Net::Ping::External.new('localhost')

The external ping uses your system's ping command. The TCP ping tries
to connect to the host via a Ruby TCPSocket.

Regards,

Dan

thanks Dan
indeed i mist the methode stupid off me
thanks for the fast reply and the explanation

···

--
Posted via http://www.ruby-forum.com/\.