Sha256: 43a4d5f68676cebcc6cdd86513ec189e9a6753ddaf83078ac0e9815b6f1c9c72

Contents?: true

Size: 1.17 KB

Versions: 43

Compression:

Stored size: 1.17 KB

Contents

require 'rex/socket'
require 'rex/io/stream'

###
#
# This class provides methods for interacting with a TCP client connection.
#
###
module Rex::Socket::Tcp

	include Rex::Socket
	include Rex::IO::Stream
	
	##
	#
	# Factory
	#
	##

	#
	# Creates the client using the supplied hash.
	#
	def self.create(hash = {})
		hash['Proto'] = 'tcp' 
		self.create_param(Rex::Socket::Parameters.from_hash(hash))
	end

	#
	# Wrapper around the base socket class' creation method that automatically
	# sets the parameter's protocol to TCP.
	#
	def self.create_param(param)
		param.proto = 'tcp'
		Rex::Socket.create_param(param)
	end

	##
	#
	# Stream mixin implementations
	#
	##

	#
	# Calls shutdown on the TCP connection.
	#
	def shutdown(how = ::Socket::SHUT_RDWR)
		begin
			return (super(how) == 0)
		rescue ::Exception
		end
	end

	#
	# Returns peer information (host + port) in host:port format.
	#
	def peerinfo
		if (pi = getpeername)
			return pi[1] + ':' + pi[2].to_s
		end
	end

	#
	# Returns local information (host + port) in host:port format.
	#
	def localinfo
		if (pi = getlocalname)
			return pi[1] + ':' + pi[2].to_s
		end
	end

	# returns socket type
	def type?
		return 'tcp'
	end

end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
librex-0.0.65 lib/rex/socket/tcp.rb
librex-0.0.63 lib/rex/socket/tcp.rb
librex-0.0.54 lib/rex/socket/tcp.rb
librex-0.0.53 lib/rex/socket/tcp.rb
librex-0.0.52 lib/rex/socket/tcp.rb
librex-0.0.51 lib/rex/socket/tcp.rb
librex-0.0.50 lib/rex/socket/tcp.rb
librex-0.0.49 lib/rex/socket/tcp.rb
librex-0.0.48 lib/rex/socket/tcp.rb
librex-0.0.47 lib/rex/socket/tcp.rb
librex-0.0.46 lib/rex/socket/tcp.rb
librex-0.0.44 lib/rex/socket/tcp.rb
librex-0.0.43 lib/rex/socket/tcp.rb
librex-0.0.42 lib/rex/socket/tcp.rb
librex-0.0.41 lib/rex/socket/tcp.rb
librex-0.0.40 lib/rex/socket/tcp.rb
librex-0.0.39 lib/rex/socket/tcp.rb
librex-0.0.38 lib/rex/socket/tcp.rb
librex-0.0.37 lib/rex/socket/tcp.rb
librex-0.0.36 lib/rex/socket/tcp.rb