summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-17 21:05:25 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-17 21:05:25 +0000
commit97591e82d9ba3b7204110302b52540007ff081a5 (patch)
tree9c425fe8dd74187b8d420eb8b5d031e5edb70487 /lib
parent51b031093069dd4a89e25b6057f1eca8c0c7e24e (diff)
* lib/ping.rb, lib/readbytes.rb: removed
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14283 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/README3
-rw-r--r--lib/ping.rb64
-rw-r--r--lib/readbytes.rb41
3 files changed, 0 insertions, 108 deletions
diff --git a/lib/README b/lib/README
index 1df5197e8b..52a5e199f2 100644
--- a/lib/README
+++ b/lib/README
@@ -1,7 +1,6 @@
English.rb lets Perl'ish global variables have English names
README this file
benchmark.rb a benchmark utility
-cgi-lib.rb simple CGI support library (old style)
cgi.rb CGI support library
cgi/session.rb CGI session class
complex.rb complex number support
@@ -45,7 +44,6 @@ ostruct.rb python style object
parsearg.rb argument parser using getopts
parsedate.rb parses date string (obsolete)
pathname.rb Object-Oriented Pathname Class
-ping.rb checks whether host is up, using TCP echo.
pp.rb pretty print objects
prettyprint.rb pretty printing algorithm
profile.rb runs ruby profiler
@@ -54,7 +52,6 @@ pstore.rb persistent object strage using marshal
racc/parser.rb racc (Ruby yACC) runtime
rational.rb rational number support
rdoc source-code documentation tool
-readbytes.rb define IO#readbytes
resolv-replace.rb replace Socket DNS by resolve.rb
resolv.rb DNS resolver in Ruby
rexml an XML parser for Ruby, in Ruby
diff --git a/lib/ping.rb b/lib/ping.rb
deleted file mode 100644
index c2966b619c..0000000000
--- a/lib/ping.rb
+++ /dev/null
@@ -1,64 +0,0 @@
-#
-# = ping.rb: Check a host for upness
-#
-# Author:: Yukihiro Matsumoto
-# Documentation:: Konrad Meyer
-#
-# Performs the function of the basic network testing tool, ping.
-# See: Ping.
-#
-
-require 'timeout'
-require "socket"
-
-#
-# Ping contains routines to test for the reachability of remote hosts.
-# Currently the only routine implemented is pingecho().
-#
-# Ping.pingecho uses a TCP echo (not an ICMP echo) to determine if the
-# remote host is reachable. This is usually adequate to tell that a remote
-# host is available to telnet, ftp, or ssh to.
-#
-# Warning: Ping.pingecho may block for a long time if DNS resolution is
-# slow. Requiring 'resolv-replace' allows non-blocking name resolution.
-#
-# Usage:
-#
-# require 'ping'
-#
-# puts "'jimmy' is alive and kicking" if Ping.pingecho('jimmy', 10)
-#
-module Ping
-
- #
- # Return true if we can open a connection to the hostname or IP address
- # +host+ on port +service+ (which defaults to the "echo" port) waiting up
- # to +timeout+ seconds.
- #
- # Example:
- #
- # require 'ping'
- #
- # Ping.pingecho "google.com", 10, 80
- #
- def pingecho(host, timeout=5, service="echo")
- begin
- timeout(timeout) do
- s = TCPSocket.new(host, service)
- s.close
- end
- rescue Errno::ECONNREFUSED
- return true
- rescue Timeout::Error, StandardError
- return false
- end
- return true
- end
- module_function :pingecho
-end
-
-if $0 == __FILE__
- host = ARGV[0]
- host ||= "localhost"
- printf("%s alive? - %s\n", host, Ping::pingecho(host, 5))
-end
diff --git a/lib/readbytes.rb b/lib/readbytes.rb
deleted file mode 100644
index ebb5fc0bd4..0000000000
--- a/lib/readbytes.rb
+++ /dev/null
@@ -1,41 +0,0 @@
-# TruncatedDataError is raised when IO#readbytes fails to read enough data.
-
-class TruncatedDataError<IOError
- def initialize(mesg, data) # :nodoc:
- @data = data
- super(mesg)
- end
-
- # The read portion of an IO#readbytes attempt.
- attr_reader :data
-end
-
-class IO
- # Reads exactly +n+ bytes.
- #
- # If the data read is nil an EOFError is raised.
- #
- # If the data read is too short a TruncatedDataError is raised and the read
- # data is obtainable via its #data method.
- def readbytes(n)
- str = read(n)
- if str == nil
- raise EOFError, "End of file reached"
- end
- if str.size < n
- raise TruncatedDataError.new("data truncated", str)
- end
- str
- end
-end
-
-if __FILE__ == $0
- begin
- loop do
- print STDIN.readbytes(6)
- end
- rescue TruncatedDataError
- p $!.data
- raise
- end
-end