Files
metasploit-gs/lib/rex/ui/text/input/socket.rb
T
Matt Miller d50ddd5edb fix for suspending meterp
git-svn-id: file:///home/svn/incoming/trunk@3185 4d416f70-5f16-0410-b530-b9f4589650da
2005-12-07 03:40:09 +00:00

66 lines
803 B
Ruby

require 'rex/ui'
module Rex
module Ui
module Text
###
#
# This class implements input against a socket.
#
###
class Input::Socket < Rex::Ui::Text::Input
def initialize(sock)
@sock = sock
end
#
# Sockets do not currently support readline.
#
def supports_readline
false
end
#
# Reads input from the raw socket.
#
def sysread(len = 1)
@sock.sysread(1)
end
#
# Wait for a line of input to be read from a socket.
#
def gets
return @sock.gets
end
#
# Print a prompt and flush to the socket.
#
def _print_prompt(prompt)
@sock.write(prompt)
@sock.flush
prompt
end
#
# Returns whether or not EOF has been reached on stdin.
#
def eof?
@sock.closed?
end
#
# Returns the file descriptor associated with a socket.
#
def fd
return @sock
end
end
end
end
end