diff options
| author | jeg2 <jeg2@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-05-01 14:57:40 +0000 |
|---|---|---|
| committer | jeg2 <jeg2@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-05-01 14:57:40 +0000 |
| commit | 8464e95cf59fc8fcfd26b415bf3e252c8a983421 (patch) | |
| tree | a1aca3f83fe3756a0485641cfcc43e6ccc58d145 /lib | |
| parent | ee6388949e4b3be562e349be999c8425aba9398c (diff) | |
| download | ruby-8464e95cf59fc8fcfd26b415bf3e252c8a983421.tar.gz ruby-8464e95cf59fc8fcfd26b415bf3e252c8a983421.tar.xz ruby-8464e95cf59fc8fcfd26b415bf3e252c8a983421.zip | |
* lib/net/telnet.rb: This patch from Brian Candler adds a FailEOF mode which
can be activated to have net/telnet raise EOFError exceptions when the
remote connection is closed. The default behavior remains unchanged though.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@16257 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/net/telnet.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/net/telnet.rb b/lib/net/telnet.rb index 1d38ee91f..d2433554a 100644 --- a/lib/net/telnet.rb +++ b/lib/net/telnet.rb @@ -523,10 +523,15 @@ module Net # value specified when this instance was created will be # used, or, failing that, the default value of 0 seconds, # which means not to wait for more input. + # FailEOF:: if true, when the remote end closes the connection then an + # EOFError will be raised. Otherwise, defaults to the old + # behaviour that the function will return whatever data + # has been received already, or nil if nothing was received. # def waitfor(options) # :yield: recvdata time_out = @options["Timeout"] waittime = @options["Waittime"] + fail_eof = @options["FailEOF"] if options.kind_of?(Hash) prompt = if options.has_key?("Match") @@ -538,6 +543,7 @@ module Net end time_out = options["Timeout"] if options.has_key?("Timeout") waittime = options["Waittime"] if options.has_key?("Waittime") + fail_eof = options["FailEOF"] if options.has_key?("FailEOF") else prompt = options end @@ -589,6 +595,7 @@ module Net line += buf yield buf if block_given? rescue EOFError # End of file reached + raise if fail_eof if line == '' line = nil yield nil if block_given? |
