Net::PingExternal gives an errror

Y

Younes Baghor

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
 
S

Sandor Szuecs

Hello there,
=20
I'm having a problem with a tutorial to ping whatever.
I have snowleopard and both ruby's both give the same error:
=20
uninitialized constant Net::pingExternal (NameError)
=20
here is the code i'm using:
=20
require 'rubygems'
require 'net/ping'
if Net::pingExternal.new('localhost').ping
puts 'Localhost OK'
else
puts 'Localhost NO respons'
end


# gem i net-ping

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

All the best, Sandor Sz=FCcs
--
 
D

Daniel Berger

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)

Try Net::ping::External

Regards,

Dan
 
Y

Younes Baghor

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
 
D

Daniel Berger

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

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

if Net::ping::External.new('loccalhost')
=A0 puts 'OK'
else
=A0 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 =A0know 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
 
Y

Younes Baghor

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


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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
474,145
Messages
2,570,826
Members
47,371
Latest member
Brkaa

Latest Threads

Top