net-ping 1.4.1-x86-mingw32 → 1.5.3-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
data/MANIFEST CHANGED
@@ -1,23 +1,25 @@
1
- * MANIFEST
2
- * CHANGES
3
- * Rakefile
4
- * README
5
- * net-ping.gemspec
6
- * examples/example_pingexternal.rb
7
- * examples/example_pinghttp.rb
8
- * examples/example_pingtcp.rb
9
- * examples/example_pingudp.rb
10
- * lib/net/ping.rb
11
- * lib/net/ping/icmp.rb
12
- * lib/net/ping/tcp.rb
13
- * lib/net/ping/udp.rb
14
- * lib/net/ping/wmi.rb
15
- * lib/net/ping/http.rb
16
- * lib/net/ping/external.rb
17
- * test/test_net_ping_external.rb
18
- * test/test_net_ping_http.rb
19
- * test/test_net_ping_icmp.rb
20
- * test/test_net_ping_tcp.rb
21
- * test/test_net_ping_udp.rb
22
- * test/test_net_ping_wmi.rb
23
- * test/test_net_ping.rb
1
+ * MANIFEST
2
+ * CHANGES
3
+ * Rakefile
4
+ * README
5
+ * net-ping.gemspec
6
+ * examples/example_pingexternal.rb
7
+ * examples/example_pinghttp.rb
8
+ * examples/example_pingtcp.rb
9
+ * examples/example_pingudp.rb
10
+ * lib/net/ping.rb
11
+ * lib/net/ping/icmp.rb
12
+ * lib/net/ping/ldap.rb
13
+ * lib/net/ping/tcp.rb
14
+ * lib/net/ping/udp.rb
15
+ * lib/net/ping/wmi.rb
16
+ * lib/net/ping/http.rb
17
+ * lib/net/ping/external.rb
18
+ * test/test_net_ping_external.rb
19
+ * test/test_net_ping_http.rb
20
+ * test/test_net_ping_icmp.rb
21
+ * test/test_net_ping_ldap.rb
22
+ * test/test_net_ping_tcp.rb
23
+ * test/test_net_ping_udp.rb
24
+ * test/test_net_ping_wmi.rb
25
+ * test/test_net_ping.rb
data/README CHANGED
@@ -1,46 +1,52 @@
1
- == Description
2
- A collection of classes that provide different ways to ping computers.
3
-
4
- == Prerequisites
5
- * The win32-open3 (1.8.x) and windows-pr libraries are required on
6
- MS Windows when using the Net::Ping::External class unless you're
7
- using JRuby.
8
-
9
- == Installation
10
- gem install net-ping
11
-
12
- == Notes
13
- Please read the documentation under the 'doc' directory. Especially pay
14
- attention to the documentation pertaining to ECONNREFUSED and TCP pings.
15
-
16
- Also note the documentation regarding down hosts.
17
-
18
- You do not need win32-open3 with Ruby 1.9.x. The open3 library that ships
19
- as part of the Ruby standard library should work.
20
-
21
- == How to require net-ping
22
- You can do either this:
23
-
24
- require 'net/ping'
25
-
26
- In which case you will get Net::Ping and all of its subclasses. Or,
27
- you can load individual subclasses like this:
28
-
29
- require 'net/ping/tcp'
30
-
31
- The former has the advantage of being easier to remember and all inclusive,
32
- not to mention backwards compatible. The latter has the advantage of
33
- reducing your memory footprint.
34
-
35
- == Known Issues
36
- Older versions of Ruby 1.9.x may not work with UDP pings.
37
- Older versions of JRuby will return false positives in UDP pings
38
- because of an incorrect error class being raised. See JRuby-4896.
39
-
40
- == License
41
- Artistic 2.0
42
-
43
- == More documentation
44
- If you installed this library via Rubygems, you can view the inline
45
- documentation via ri or fire up 'gem server', and point your browser at
46
- http://localhost:8808.
1
+ == Description
2
+ A collection of classes that provide different ways to ping computers.
3
+
4
+ == Prerequisites
5
+ The win32-open3 (1.8.x) and windows-pr libraries are required on
6
+ MS Windows when using the Net::Ping::External class unless you're
7
+ using JRuby.
8
+
9
+ JRuby users should use 1.6.7 or later.
10
+
11
+ == Installation
12
+ gem install net-ping
13
+
14
+ == Notes
15
+ Please read the documentation under the 'doc' directory. Especially pay
16
+ attention to the documentation pertaining to ECONNREFUSED and TCP pings.
17
+
18
+ Also note the documentation regarding down hosts.
19
+
20
+ You do not need win32-open3 with Ruby 1.9.x. The open3 library that ships
21
+ as part of the Ruby standard library should work.
22
+
23
+ == How to require net-ping
24
+ You can do either this:
25
+
26
+ require 'net/ping'
27
+
28
+ In which case you will get Net::Ping and all of its subclasses. Or,
29
+ you can load individual subclasses like this:
30
+
31
+ require 'net/ping/tcp'
32
+
33
+ The former has the advantage of being easier to remember and all inclusive,
34
+ not to mention backwards compatible. The latter has the advantage of
35
+ reducing your memory footprint.
36
+
37
+ == Known Issues
38
+ Older versions of Ruby 1.9.x may not work with UDP pings.
39
+
40
+ Older versions of JRuby will return false positives in UDP pings
41
+ because of an incorrect error class being raised. See JRuby-4896.
42
+
43
+ JRuby 1.6.7 or later is required for external pings because of a bug
44
+ in earlier versions with open3 and stream handling.
45
+
46
+ == License
47
+ Artistic 2.0
48
+
49
+ == More documentation
50
+ If you installed this library via Rubygems, you can view the inline
51
+ documentation via ri or fire up 'gem server', and point your browser at
52
+ http://localhost:8808.
data/Rakefile CHANGED
@@ -1,89 +1,100 @@
1
- require 'rake'
2
- require 'rake/clean'
3
- require 'rake/testtask'
4
- include Config
5
-
6
- CLEAN.include("**/*.gem", "**/*.rbc")
7
-
8
- namespace 'gem' do
9
- desc 'Create the net-ping gem'
10
- task :create => [:clean] do
11
- spec = eval(IO.read('net-ping.gemspec'))
12
- Gem::Builder.new(spec).build
13
- end
14
-
15
- desc 'Install the net-ping gem'
16
- task :install => [:create] do
17
- gem_file = Dir["*.gem"].first
18
- sh "gem install #{gem_file}"
19
- end
20
- end
21
-
22
- namespace 'example' do
23
- desc 'Run the external ping example program'
24
- task :external do
25
- ruby '-Ilib examples/example_pingexternal.rb'
26
- end
27
-
28
- desc 'Run the http ping example program'
29
- task :http do
30
- ruby '-Ilib examples/example_pinghttp.rb'
31
- end
32
-
33
- desc 'Run the tcp ping example program'
34
- task :tcp do
35
- ruby '-Ilib examples/example_pingtcp.rb'
36
- end
37
-
38
- desc 'Run the udp ping example program'
39
- task :udp do
40
- ruby '-Ilib examples/example_pingudp.rb'
41
- end
42
- end
43
-
44
- Rake::TestTask.new do |t|
45
- t.libs << 'test'
46
- t.warning = true
47
- t.verbose = true
48
- t.test_files = FileList['test/test_net_ping.rb']
49
- end
50
-
51
- namespace 'test' do
52
- Rake::TestTask.new('external') do |t|
53
- t.warning = true
54
- t.verbose = true
55
- t.test_files = FileList['test/test_net_ping_external.rb']
56
- end
57
-
58
- Rake::TestTask.new('http') do |t|
59
- t.warning = true
60
- t.verbose = true
61
- t.test_files = FileList['test/test_net_ping_http.rb']
62
- end
63
-
64
- Rake::TestTask.new('icmp') do |t|
65
- t.warning = true
66
- t.verbose = true
67
- t.test_files = FileList['test/test_net_ping_icmp.rb']
68
- end
69
-
70
- Rake::TestTask.new('tcp') do |t|
71
- t.warning = true
72
- t.verbose = true
73
- t.test_files = FileList['test/test_net_ping_tcp.rb']
74
- end
75
-
76
- Rake::TestTask.new('udp') do |t|
77
- t.warning = true
78
- t.verbose = true
79
- t.test_files = FileList['test/test_net_ping_udp.rb']
80
- end
81
-
82
- Rake::TestTask.new('wmi') do |t|
83
- t.warning = true
84
- t.verbose = true
85
- t.test_files = FileList['test/test_net_ping_wmi.rb']
86
- end
87
- end
88
-
89
- task :default => :test
1
+ require 'rake'
2
+ require 'rake/clean'
3
+ require 'rake/testtask'
4
+ include Object.const_defined?(:RbConfig) ? RbConfig : Config
5
+
6
+ CLEAN.include("**/*.gem", "**/*.rbc")
7
+
8
+ namespace 'gem' do
9
+ desc 'Create the net-ping gem'
10
+ task :create => [:clean] do
11
+ spec = eval(IO.read('net-ping.gemspec'))
12
+ Gem::Builder.new(spec).build
13
+ end
14
+
15
+ desc 'Install the net-ping gem'
16
+ task :install => [:create] do
17
+ gem_file = Dir["*.gem"].first
18
+ sh "gem install #{gem_file}"
19
+ end
20
+ end
21
+
22
+ namespace 'example' do
23
+ desc 'Run the external ping example program'
24
+ task :external do
25
+ ruby '-Ilib examples/example_pingexternal.rb'
26
+ end
27
+
28
+ desc 'Run the http ping example program'
29
+ task :http do
30
+ ruby '-Ilib examples/example_pinghttp.rb'
31
+ end
32
+
33
+ desc 'Run the tcp ping example program'
34
+ task :tcp do
35
+ ruby '-Ilib examples/example_pingtcp.rb'
36
+ end
37
+
38
+ desc 'Run the udp ping example program'
39
+ task :udp do
40
+ ruby '-Ilib examples/example_pingudp.rb'
41
+ end
42
+
43
+ desc 'Run the ldap ping example program'
44
+ task :ldap do
45
+ ruby '-Ilib examples/example_pingldap.rb'
46
+ end
47
+ end
48
+
49
+ Rake::TestTask.new do |t|
50
+ t.libs << 'test'
51
+ t.warning = true
52
+ t.verbose = true
53
+ t.test_files = FileList['test/test_net_ping.rb']
54
+ end
55
+
56
+ namespace 'test' do
57
+ Rake::TestTask.new('external') do |t|
58
+ t.warning = true
59
+ t.verbose = true
60
+ t.test_files = FileList['test/test_net_ping_external.rb']
61
+ end
62
+
63
+ Rake::TestTask.new('http') do |t|
64
+ t.warning = true
65
+ t.verbose = true
66
+ t.test_files = FileList['test/test_net_ping_http.rb']
67
+ end
68
+
69
+ Rake::TestTask.new('icmp') do |t|
70
+ t.warning = true
71
+ t.verbose = true
72
+ t.test_files = FileList['test/test_net_ping_icmp.rb']
73
+ end
74
+
75
+ Rake::TestTask.new('tcp') do |t|
76
+ t.warning = true
77
+ t.verbose = true
78
+ t.test_files = FileList['test/test_net_ping_tcp.rb']
79
+ end
80
+
81
+ Rake::TestTask.new('udp') do |t|
82
+ t.warning = true
83
+ t.verbose = true
84
+ t.test_files = FileList['test/test_net_ping_udp.rb']
85
+ end
86
+
87
+ Rake::TestTask.new('wmi') do |t|
88
+ t.warning = true
89
+ t.verbose = true
90
+ t.test_files = FileList['test/test_net_ping_wmi.rb']
91
+ end
92
+
93
+ Rake::TestTask.new('ldap') do |t|
94
+ t.warning = true
95
+ t.verbose = true
96
+ t.test_files = FileList['test/test_net_ping_ldap.rb']
97
+ end
98
+ end
99
+
100
+ task :default => :test
data/doc/ping.txt CHANGED
@@ -1,249 +1,274 @@
1
- = Description
2
- A simple Ruby interface to the 'ping' command.
3
-
4
- = Synopsis
5
- require 'net/ping'
6
- include Net
7
-
8
- Ping::TCP.service_check = true
9
-
10
- pt = Net::Ping::TCP.new(host)
11
- pu = Net::Ping::UDP.new(host)
12
- pe = Net::Ping::External.new(host)
13
- ph = Net::Ping::HTTP.new(uri)
14
-
15
- if pt.ping
16
- puts "TCP ping successful"
17
- else
18
- puts "TCP ping unsuccessful: " + pt.exception
19
- end
20
-
21
- if pu.ping
22
- puts "UDP ping successful"
23
- else
24
- puts "UDP ping unsuccessful: " + pu.exception
25
- end
26
-
27
- if pe.ping
28
- puts "External ping successful"
29
- else
30
- puts "External ping unsuccessful: " + pe.exception
31
- end
32
-
33
- if ph.ping?
34
- puts "HTTP ping successful"
35
- else
36
- puts "HTTP ping unsuccessful: " + ph.exception
37
- end
38
-
39
- = Ping Classes
40
- * Ping::TCP
41
- * Ping::UDP
42
- * Ping::External
43
- * Ping::HTTP
44
- * Ping::ICMP
45
- * Ping::WMI
46
-
47
- All Ping classes are children of the Ping parent class (which should
48
- never be instantiated directly).
49
-
50
- The Ping::ICMP class requires root privileges on UNIX systems.
51
-
52
- The Ping::WMI class only works on MS Windows.
53
-
54
- == Net::Ping
55
- Net::Ping.new(host=nil, port=7, timeout=5)
56
- Creates and returns a new Ping object. If the host is not specified
57
- in the constructor then it must be specified in the ping method.
58
-
59
- == Net::Ping::TCP
60
- Ping::TCP.service_check
61
- Returns the setting for how ECONNREFUSED is handled. By default, this is
62
- set to false, i.e. an ECONNREFUSED error is considered a failed ping.
63
-
64
- Ping::TCP.service_check=(bool)
65
- Sets the behavior for how ECONNREFUSED is handled. By default, this is
66
- set to false, i.e. an ECONNREFUSED error is considered a failed ping.
67
-
68
- Ping::TCP#ping(host=nil)
69
- Attempts to open a connection using TCPSocket with a +host+ specified
70
- either here or in the constructor. A successful open means the ping was
71
- successful and true is returned. Otherwise, false is returned.
72
-
73
- == Net::Ping::UDP
74
- Ping::UDP#ping
75
- Attempts to open a connection using UDPSocket and sends the value of
76
- Ping::UDP#data as a string across the socket. If the return string matches,
77
- then the ping was successful and true is returned. Otherwise, false is
78
- returned.
79
-
80
- Ping::UDP#data
81
- Returns the string that is sent across the UDP socket.
82
-
83
- Ping::UDP#data=(string)
84
- Sets the string that is sent across the UDP socket. The default is "ping".
85
- Note that the +string+ cannot be larger than MAX_DATA (64 characters).
86
-
87
- == Net::Ping::External
88
- Ping::External#ping
89
- Uses the 'open3' module and calls your system's local 'ping' command with
90
- various options, depending on platform. If nothing is sent to stderr, the
91
- ping was successful and true is returned. Otherwise, false is returned.
92
-
93
- The MS Windows platform requires the 'win32-open3' package.
94
-
95
- == Ping::HTTP
96
- Ping::HTTP.new(uri=nil, port=80, timeout=5)
97
- Identical to Net::Ping.new except that, instead of a host, the first
98
- argument is a URI.
99
-
100
- Ping::HTTP#ping
101
- Checks for a response against +uri+. As long as kind of Net::HTTPSuccess
102
- response is returned, the ping is successful and true is returned.
103
- Otherwise, false is returned and Ping::HTTP#exception is set to the error
104
- message.
105
-
106
- Note that redirects are automatically followed unless the
107
- Ping::HTTP#follow_redirects method is set to false.
108
-
109
- Ping::HTTP#follow_redirect
110
- Indicates whether or not a redirect should be followed in a ping attempt.
111
- By default this is set to true.
112
-
113
- Ping::HTTP#follow_redirect=(bool)
114
- Sets whether or not a redirect should be followed in a ping attempt. If
115
- set to false, then any redirect is considered a failed ping.
116
-
117
- Ping::HTTP#uri
118
- An alias for Ping::HTTP#host.
119
-
120
- Ping::HTTP#uri=(uri)
121
- An alias for Ping::HTTP#host=.
122
-
123
- == Ping::ICMP
124
- Ping::ICMP#duration
125
- The time it took to ping the host. Not a precise value but a good estimate.
126
-
127
- == Ping::WMI
128
- Ping::WMI#ping(host, options={})
129
- Unlike other Ping classes, this method returns a PingStatus struct that
130
- contains various bits of information about the ping itself. The PingStatus
131
- struct is a wrapper for the Win32_PingStatus WMI class.
132
-
133
- In addition, you can pass options that will be interpreted as WQL parameters.
134
-
135
- Ping::WMI#ping?(host, options={})
136
- Returns whether or not the ping succeeded.
137
-
138
- = Common Instance Methods
139
- Ping#exception
140
- Returns the error string that was set if a ping call failed. If an exception
141
- is raised, it is caught and stored in this attribute. It is not raised in
142
- your code.
143
-
144
- This should be nil if the ping succeeded.
145
-
146
- Ping#host
147
- Returns the host name that ping attempts will ping against.
148
-
149
- Ping#host=(hostname)
150
- Sets the host name that ping attempts will ping against.
151
-
152
- Ping#port
153
- Returns the port number that ping attempts will use.
154
-
155
- Ping#port=(port)
156
- Set the port number to open socket connections on. The default is 7 (or
157
- whatever your 'echo' port is set to). Note that you can also specify a
158
- string, such as "http".
159
-
160
- Ping#timeout
161
- Returns the amount of time before the timeout module raises a TimeoutError
162
- during connection attempts. The default is 5 seconds.
163
-
164
- Ping#timeout=(time)
165
- Sets the amount of time before the timeout module raises a TimeoutError.
166
- during connection attempts.
167
-
168
- Ping#warning
169
- Returns a warning string that was returned during the ping attempt. This
170
- typically occurs only in the Ping::External class, or the Ping::HTTP class
171
- if a redirect occurred.
172
-
173
- == Notes
174
- If a host is down *IT IS CONSIDERED A FAILED PING*, and the 'no answer from
175
- +host+' text is assigned to the 'exception' attribute. You may disagree with
176
- this behavior, in which case you need merely check the exception attribute
177
- against a regex as a simple workaround.
178
-
179
- == Pre-emptive FAQ
180
- Q: "Why don't you return exceptions if a connection fails?"
181
-
182
- A: Because ping is only meant to return one of two things - success or
183
- failure. It's very simple. If you want to find out *why* the ping
184
- failed, you can check the 'exception' attribute.
185
-
186
- Q: "I know the host is alive, but a TCP or UDP ping tells me otherwise. What
187
- gives?"
188
-
189
- A: It's possible that the echo port has been disabled on the remote
190
- host for security reasons. Your best best is to specify a different port
191
- or to use Ping::ICMP or Ping::External instead.
192
-
193
- In the case of UDP pings, they are often actively refused. It may be
194
- more pragmatic to set Ping::UDP.service_check = false.
195
-
196
- Q: "Why does a TCP ping return false when I know it should return true?"
197
-
198
- A: By default ECONNREFUSED errors will return a value of false. This is
199
- contrary to what most other folks do for TCP pings. The problem with
200
- their philosophy is that you can get false positives if a firewall blocks
201
- the route to the host. The problem with my philosophy is that you can
202
- get false negatives if there is no firewall (or it's not blocking the
203
- route). Given the alternatives I chose the latter.
204
-
205
- You can always change the default behavior by using the +service_check+
206
- class method.
207
-
208
- A similar situation is true for UDP pings.
209
-
210
- Q: "Couldn't you use traceroute information to tell for sure?"
211
-
212
- A: I could but I won't so don't bug me about it. It's far more effort than
213
- it's worth. If you want something like that, please port the
214
- Net::Traceroute Perl module by Daniel Hagerty.
215
-
216
- = Known Bugs
217
- You may see a test failure from the test_net_ping_tcp test case. You can
218
- ignore these.
219
-
220
- The socket library that ships with the Windows One-Click installer has
221
- known issues. This may cause the Ping::ICMP class to fail. In fact, I
222
- make an effort to skip those tests if I detect the one-click installer.
223
-
224
- UDP pings may not work with older versions of Ruby 1.9.x.
225
-
226
- Please report any bugs on the project page at
227
- http://www.rubyforge.org/projects/shards.
228
-
229
- = Acknowledgements
230
- The Ping::ICMP#ping method is based largely on the identical method from
231
- the Net::Ping Perl module by Rob Brown. Much of the code was ported by
232
- Jos Backus on ruby-talk.
233
-
234
- = Future Plans
235
- Add support for syn pings.
236
-
237
- = License
238
- Artistic 2.0
239
-
240
- = Copyright
241
- (C) 2003-2010 Daniel J. Berger, All Rights Reserved
242
-
243
- = Warranty
244
- This package is provided "as is" and without any express or
245
- implied warranties, including, without limitation, the implied
246
- warranties of merchantability and fitness for a particular purpose.
247
-
248
- = Author
249
- Daniel J. Berger
1
+ = Description
2
+ A simple Ruby interface to the 'ping' command.
3
+
4
+ = Synopsis
5
+ require 'net/ping'
6
+ include Net
7
+
8
+ Ping::TCP.service_check = true
9
+
10
+ pt = Net::Ping::TCP.new(host)
11
+ pu = Net::Ping::UDP.new(host)
12
+ pe = Net::Ping::External.new(host)
13
+ ph = Net::Ping::HTTP.new(uri)
14
+
15
+ if pt.ping
16
+ puts "TCP ping successful"
17
+ else
18
+ puts "TCP ping unsuccessful: " + pt.exception
19
+ end
20
+
21
+ if pu.ping
22
+ puts "UDP ping successful"
23
+ else
24
+ puts "UDP ping unsuccessful: " + pu.exception
25
+ end
26
+
27
+ if pe.ping
28
+ puts "External ping successful"
29
+ else
30
+ puts "External ping unsuccessful: " + pe.exception
31
+ end
32
+
33
+ if ph.ping?
34
+ puts "HTTP ping successful"
35
+ else
36
+ puts "HTTP ping unsuccessful: " + ph.exception
37
+ end
38
+
39
+ = Ping Classes
40
+ * Ping::TCP
41
+ * Ping::UDP
42
+ * Ping::External
43
+ * Ping::HTTP
44
+ * Ping::ICMP
45
+ * Ping::WMI
46
+ * Ping::LDAP
47
+
48
+ All Ping classes are children of the Ping parent class (which should
49
+ never be instantiated directly).
50
+
51
+ The Ping::ICMP class requires root privileges on UNIX systems.
52
+
53
+ The Ping::WMI class only works on MS Windows.
54
+
55
+ == Net::Ping
56
+ Net::Ping.new(host=nil, port=7, timeout=5)
57
+ Creates and returns a new Ping object. If the host is not specified
58
+ in the constructor then it must be specified in the ping method.
59
+
60
+ == Net::Ping::TCP
61
+ Ping::TCP.service_check
62
+ Returns the setting for how ECONNREFUSED is handled. By default, this is
63
+ set to false, i.e. an ECONNREFUSED error is considered a failed ping.
64
+
65
+ Ping::TCP.service_check=(bool)
66
+ Sets the behavior for how ECONNREFUSED is handled. By default, this is
67
+ set to false, i.e. an ECONNREFUSED error is considered a failed ping.
68
+
69
+ Ping::TCP#ping(host=nil)
70
+ Attempts to open a connection using TCPSocket with a +host+ specified
71
+ either here or in the constructor. A successful open means the ping was
72
+ successful and true is returned. Otherwise, false is returned.
73
+
74
+ == Net::Ping::UDP
75
+ Ping::UDP#ping
76
+ Attempts to open a connection using UDPSocket and sends the value of
77
+ Ping::UDP#data as a string across the socket. If the return string matches,
78
+ then the ping was successful and true is returned. Otherwise, false is
79
+ returned.
80
+
81
+ Ping::UDP#data
82
+ Returns the string that is sent across the UDP socket.
83
+
84
+ Ping::UDP#data=(string)
85
+ Sets the string that is sent across the UDP socket. The default is "ping".
86
+ Note that the +string+ cannot be larger than MAX_DATA (64 characters).
87
+
88
+ == Net::Ping::External
89
+ Ping::External#ping
90
+ Uses the 'open3' module and calls your system's local 'ping' command with
91
+ various options, depending on platform. If nothing is sent to stderr, the
92
+ ping was successful and true is returned. Otherwise, false is returned.
93
+
94
+ The MS Windows platform requires the 'win32-open3' package.
95
+
96
+ == Ping::HTTP
97
+ Ping::HTTP.new(uri=nil, port=80, timeout=5)
98
+ Identical to Net::Ping.new except that, instead of a host, the first
99
+ argument is a URI.
100
+
101
+ Ping::HTTP#ping
102
+ Checks for a response against +uri+. As long as kind of Net::HTTPSuccess
103
+ response is returned, the ping is successful and true is returned.
104
+ Otherwise, false is returned and Ping::HTTP#exception is set to the error
105
+ message.
106
+
107
+ Note that redirects are automatically followed unless the
108
+ Ping::HTTP#follow_redirects method is set to false.
109
+
110
+ Ping::HTTP#follow_redirect
111
+ Indicates whether or not a redirect should be followed in a ping attempt.
112
+ By default this is set to true.
113
+
114
+ Ping::HTTP#follow_redirect=(bool)
115
+ Sets whether or not a redirect should be followed in a ping attempt. If
116
+ set to false, then any redirect is considered a failed ping.
117
+
118
+ Ping::HTTP#uri
119
+ An alias for Ping::HTTP#host.
120
+
121
+ Ping::HTTP#uri=(uri)
122
+ An alias for Ping::HTTP#host=.
123
+
124
+ == Ping::ICMP
125
+ Ping::ICMP#duration
126
+ The time it took to ping the host. Not a precise value but a good estimate.
127
+
128
+ == Ping::WMI
129
+ Ping::WMI#ping(host, options={})
130
+ Unlike other Ping classes, this method returns a PingStatus struct that
131
+ contains various bits of information about the ping itself. The PingStatus
132
+ struct is a wrapper for the Win32_PingStatus WMI class.
133
+
134
+ In addition, you can pass options that will be interpreted as WQL parameters.
135
+
136
+ Ping::WMI#ping?(host, options={})
137
+ Returns whether or not the ping succeeded.
138
+
139
+ == Ping::LDAP
140
+ Ping::LDAP.new(uri=nil, timeout=5)
141
+ Performs a 'ping' to an LDAP server in the form of either an anonymous
142
+ or an authenticated LDAP bind.
143
+ Identical to Net::Ping.new except that, instead of a host, the first
144
+ argument is a URI.
145
+ The default +timeout+ is 5 seconds.
146
+
147
+ +uri+ string is expected to be a full URI with scheme (ldap/ldaps)
148
+ and optionally the port (else default port is assumed) e.g.
149
+ ldap://my.ldap.host.com
150
+ ldap://my.ldap.host.com:1389
151
+ ldaps://my.ldap.host.com
152
+ ldaps://my.ldap.host.com:6636
153
+
154
+ If a plain hostname is provided as the +uri+, a default port of 389 is assumed
155
+
156
+ Ping::LDAP#encryption
157
+ Set/get the encyption method. By default is nil, but may be set to :simple_tls
158
+
159
+ Ping::LDAP#username
160
+ Ping::LDAP#password
161
+ set/get the username and password for ping using and authenticated bind.
162
+
163
+ = Common Instance Methods
164
+ Ping#exception
165
+ Returns the error string that was set if a ping call failed. If an exception
166
+ is raised, it is caught and stored in this attribute. It is not raised in
167
+ your code.
168
+
169
+ This should be nil if the ping succeeded.
170
+
171
+ Ping#host
172
+ Returns the host name that ping attempts will ping against.
173
+
174
+ Ping#host=(hostname)
175
+ Sets the host name that ping attempts will ping against.
176
+
177
+ Ping#port
178
+ Returns the port number that ping attempts will use.
179
+
180
+ Ping#port=(port)
181
+ Set the port number to open socket connections on. The default is 7 (or
182
+ whatever your 'echo' port is set to). Note that you can also specify a
183
+ string, such as "http".
184
+
185
+ Ping#timeout
186
+ Returns the amount of time before the timeout module raises a TimeoutError
187
+ during connection attempts. The default is 5 seconds.
188
+
189
+ Ping#timeout=(time)
190
+ Sets the amount of time before the timeout module raises a TimeoutError.
191
+ during connection attempts.
192
+
193
+ Ping#warning
194
+ Returns a warning string that was returned during the ping attempt. This
195
+ typically occurs only in the Ping::External class, or the Ping::HTTP class
196
+ if a redirect occurred.
197
+
198
+ == Notes
199
+ If a host is down *IT IS CONSIDERED A FAILED PING*, and the 'no answer from
200
+ +host+' text is assigned to the 'exception' attribute. You may disagree with
201
+ this behavior, in which case you need merely check the exception attribute
202
+ against a regex as a simple workaround.
203
+
204
+ == Pre-emptive FAQ
205
+ Q: "Why don't you return exceptions if a connection fails?"
206
+
207
+ A: Because ping is only meant to return one of two things - success or
208
+ failure. It's very simple. If you want to find out *why* the ping
209
+ failed, you can check the 'exception' attribute.
210
+
211
+ Q: "I know the host is alive, but a TCP or UDP ping tells me otherwise. What
212
+ gives?"
213
+
214
+ A: It's possible that the echo port has been disabled on the remote
215
+ host for security reasons. Your best best is to specify a different port
216
+ or to use Ping::ICMP or Ping::External instead.
217
+
218
+ In the case of UDP pings, they are often actively refused. It may be
219
+ more pragmatic to set Ping::UDP.service_check = false.
220
+
221
+ Q: "Why does a TCP ping return false when I know it should return true?"
222
+
223
+ A: By default ECONNREFUSED errors will return a value of false. This is
224
+ contrary to what most other folks do for TCP pings. The problem with
225
+ their philosophy is that you can get false positives if a firewall blocks
226
+ the route to the host. The problem with my philosophy is that you can
227
+ get false negatives if there is no firewall (or it's not blocking the
228
+ route). Given the alternatives I chose the latter.
229
+
230
+ You can always change the default behavior by using the +service_check+
231
+ class method.
232
+
233
+ A similar situation is true for UDP pings.
234
+
235
+ Q: "Couldn't you use traceroute information to tell for sure?"
236
+
237
+ A: I could but I won't so don't bug me about it. It's far more effort than
238
+ it's worth. If you want something like that, please port the
239
+ Net::Traceroute Perl module by Daniel Hagerty.
240
+
241
+ = Known Bugs
242
+ You may see a test failure from the test_net_ping_tcp test case. You can
243
+ ignore these.
244
+
245
+ The socket library that ships with the Windows One-Click installer has
246
+ known issues. This may cause the Ping::ICMP class to fail. In fact, I
247
+ make an effort to skip those tests if I detect the one-click installer.
248
+
249
+ UDP pings may not work with older versions of Ruby 1.9.x.
250
+
251
+ Please report any bugs on the project page at
252
+ http://www.rubyforge.org/projects/shards.
253
+
254
+ = Acknowledgements
255
+ The Ping::ICMP#ping method is based largely on the identical method from
256
+ the Net::Ping Perl module by Rob Brown. Much of the code was ported by
257
+ Jos Backus on ruby-talk.
258
+
259
+ = Future Plans
260
+ Add support for syn pings.
261
+
262
+ = License
263
+ Artistic 2.0
264
+
265
+ = Copyright
266
+ (C) 2003-2010 Daniel J. Berger, All Rights Reserved
267
+
268
+ = Warranty
269
+ This package is provided "as is" and without any express or
270
+ implied warranties, including, without limitation, the implied
271
+ warranties of merchantability and fitness for a particular purpose.
272
+
273
+ = Author
274
+ Daniel J. Berger