Sha256: a2cefa61ca54bbeb1e387ba633222daa421da9ae38437577d2ebbe38ba824059

Contents?: true

Size: 1022 Bytes

Versions: 57

Compression:

Stored size: 1022 Bytes

Contents

# -*- coding: binary -*-
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.
  #
  # @see create_param
  # @see Rex::Socket::Parameters.from_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 socket type
  def type?
    return 'tcp'
  end

end

Version data entries

57 entries across 57 versions & 1 rubygems

Version Path
rex-socket-0.1.59 lib/rex/socket/tcp.rb
rex-socket-0.1.58 lib/rex/socket/tcp.rb
rex-socket-0.1.57 lib/rex/socket/tcp.rb
rex-socket-0.1.56 lib/rex/socket/tcp.rb
rex-socket-0.1.55 lib/rex/socket/tcp.rb
rex-socket-0.1.54 lib/rex/socket/tcp.rb
rex-socket-0.1.53 lib/rex/socket/tcp.rb
rex-socket-0.1.52 lib/rex/socket/tcp.rb
rex-socket-0.1.51 lib/rex/socket/tcp.rb
rex-socket-0.1.50 lib/rex/socket/tcp.rb
rex-socket-0.1.49 lib/rex/socket/tcp.rb
rex-socket-0.1.48 lib/rex/socket/tcp.rb
rex-socket-0.1.47 lib/rex/socket/tcp.rb
rex-socket-0.1.46 lib/rex/socket/tcp.rb
rex-socket-0.1.45 lib/rex/socket/tcp.rb
rex-socket-0.1.44 lib/rex/socket/tcp.rb
rex-socket-0.1.43 lib/rex/socket/tcp.rb
rex-socket-0.1.42 lib/rex/socket/tcp.rb
rex-socket-0.1.41 lib/rex/socket/tcp.rb
rex-socket-0.1.40 lib/rex/socket/tcp.rb