module Rex::Socket::Tcp
This class provides methods for interacting with a TCP client connection.
Public Class Methods
create(hash = {})
click to toggle source
Creates the client using the supplied hash.
@see create_param
@see Rex::Socket::Parameters.from_hash
# File lib/rex/socket/tcp.rb, line 25 def self.create(hash = {}) hash['Proto'] = 'tcp' self.create_param(Rex::Socket::Parameters.from_hash(hash)) end
create_param(param)
click to toggle source
Wrapper around the base socket class’ creation method that automatically sets the parameter’s protocol to TCP.
# File lib/rex/socket/tcp.rb, line 34 def self.create_param(param) param.proto = 'tcp' Rex::Socket.create_param(param) end
Public Instance Methods
localinfo()
click to toggle source
Returns local information (host + port) in host:port format.
# File lib/rex/socket/tcp.rb, line 67 def localinfo if (pi = getlocalname) return pi[1] + ':' + pi[2].to_s end end
peerinfo()
click to toggle source
Returns peer information (host + port) in host:port format.
# File lib/rex/socket/tcp.rb, line 58 def peerinfo if (pi = getpeername) return pi[1] + ':' + pi[2].to_s end end
shutdown(how = ::Socket::SHUT_RDWR)
click to toggle source
Calls shutdown on the TCP connection.
Calls superclass method
# File lib/rex/socket/tcp.rb, line 48 def shutdown(how = ::Socket::SHUT_RDWR) begin return (super(how) == 0) rescue ::Exception end end
type?()
click to toggle source
returns socket type
# File lib/rex/socket/tcp.rb, line 74 def type? return 'tcp' end