2005-06-02 07:52:17 +00:00
|
|
|
require 'Rex/Socket'
|
|
|
|
require 'Rex/IO/Stream'
|
|
|
|
|
|
|
|
class Rex::Socket::Tcp < Rex::Socket
|
|
|
|
include Rex::IO::Stream
|
|
|
|
|
|
|
|
##
|
|
|
|
#
|
|
|
|
# Class initialization
|
|
|
|
#
|
|
|
|
##
|
|
|
|
|
|
|
|
def initialize(sock)
|
|
|
|
super
|
|
|
|
end
|
|
|
|
|
|
|
|
##
|
|
|
|
#
|
|
|
|
# Stream mixin implementations
|
|
|
|
#
|
|
|
|
##
|
|
|
|
|
|
|
|
def blocking=(tf)
|
|
|
|
return tf # FIXME
|
|
|
|
end
|
|
|
|
|
|
|
|
def blocking
|
|
|
|
return true # FIXME
|
|
|
|
end
|
|
|
|
|
|
|
|
def write(buf, opts = {})
|
|
|
|
return sock.syswrite(buf)
|
|
|
|
end
|
|
|
|
|
|
|
|
def read(length = nil, opts = {})
|
|
|
|
length = 16384 unless length
|
|
|
|
|
|
|
|
begin
|
|
|
|
return sock.sysread(length)
|
|
|
|
rescue EOFError
|
|
|
|
return nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2005-06-03 05:21:49 +00:00
|
|
|
def shutdown(how = SHUT_RDWR)
|
|
|
|
return (sock.shutdown(how) == 0)
|
2005-06-02 07:52:17 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def close
|
|
|
|
sock.close
|
|
|
|
end
|
|
|
|
|
|
|
|
def poll_read(timeout = nil)
|
2005-06-03 04:51:51 +00:00
|
|
|
return select([ poll_fd ], nil, nil, timeout)
|
2005-06-02 07:52:17 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def poll_fd
|
|
|
|
return sock
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|