Sha256: 48d9b947f7f24374f98f12e3972efcd686c56a36883e2ddc7c6d4ea4cf56e13f

Contents?: true

Size: 651 Bytes

Versions: 30

Compression:

Stored size: 651 Bytes

Contents

class TcpConnectionData
  attr_reader :ip_address, :port

  def initialize(hostname, port)
    @port = port
    if hostname == "localhost"
      @ip_address = "127.0.0.1"
    else
      begin
        @ip_address = IPSocket.getaddress(hostname)
      rescue SocketError
        raise "Unable to resolve hostname to an IP address."
      end
    end
  end

  def ==(other)
    other.is_a?(TcpConnectionData) && @ip_address == other.ip_address && @port == other.port
  end

  def to_s
    "#{@ip_address}:#{@port}"

  end

  def get_address_bytes
    @ip_address.split(".").map(&:to_i)
  end

  def get_port_bytes
    [@port & 0xFF, @port >> 8]
  end
end

Version data entries

30 entries across 15 versions & 1 rubygems

Version Path
javonet-ruby-sdk-2.5.4 lib/javonet-ruby-sdk/Binaries/Ruby/MacOs/X64/utils/tcp_connection_data.rb
javonet-ruby-sdk-2.5.4 lib/javonet-ruby-sdk/Binaries/Ruby/Linux/X64/utils/tcp_connection_data.rb
javonet-ruby-sdk-2.5.3 lib/javonet-ruby-sdk/Binaries/Ruby/MacOs/X64/utils/tcp_connection_data.rb
javonet-ruby-sdk-2.5.3 lib/javonet-ruby-sdk/Binaries/Ruby/Linux/X64/utils/tcp_connection_data.rb
javonet-ruby-sdk-2.5.2 lib/javonet-ruby-sdk/Binaries/Ruby/Linux/X64/utils/tcp_connection_data.rb
javonet-ruby-sdk-2.5.2 lib/javonet-ruby-sdk/Binaries/Ruby/MacOs/X64/utils/tcp_connection_data.rb
javonet-ruby-sdk-2.5.1 lib/javonet-ruby-sdk/Binaries/Ruby/MacOs/X64/utils/tcp_connection_data.rb
javonet-ruby-sdk-2.5.1 lib/javonet-ruby-sdk/Binaries/Ruby/Linux/X64/utils/tcp_connection_data.rb
javonet-ruby-sdk-2.5.0 lib/javonet-ruby-sdk/Binaries/Ruby/MacOs/X64/utils/tcp_connection_data.rb
javonet-ruby-sdk-2.5.0 lib/javonet-ruby-sdk/Binaries/Ruby/Linux/X64/utils/tcp_connection_data.rb
javonet-ruby-sdk-2.4.11 lib/javonet-ruby-sdk/Binaries/Ruby/MacOs/X64/utils/tcp_connection_data.rb
javonet-ruby-sdk-2.4.11 lib/javonet-ruby-sdk/Binaries/Ruby/Linux/X64/utils/tcp_connection_data.rb
javonet-ruby-sdk-2.4.10 lib/javonet-ruby-sdk/Binaries/Ruby/MacOs/X64/utils/tcp_connection_data.rb
javonet-ruby-sdk-2.4.10 lib/javonet-ruby-sdk/Binaries/Ruby/Linux/X64/utils/tcp_connection_data.rb
javonet-ruby-sdk-2.4.9 lib/javonet-ruby-sdk/Binaries/Ruby/MacOs/X64/utils/tcp_connection_data.rb
javonet-ruby-sdk-2.4.9 lib/javonet-ruby-sdk/Binaries/Ruby/Linux/X64/utils/tcp_connection_data.rb
javonet-ruby-sdk-2.4.8 lib/javonet-ruby-sdk/Binaries/Ruby/MacOs/X64/utils/tcp_connection_data.rb
javonet-ruby-sdk-2.4.8 lib/javonet-ruby-sdk/Binaries/Ruby/Linux/X64/utils/tcp_connection_data.rb
javonet-ruby-sdk-2.4.7 lib/javonet-ruby-sdk/Binaries/Ruby/MacOs/X64/utils/tcp_connection_data.rb
javonet-ruby-sdk-2.4.7 lib/javonet-ruby-sdk/Binaries/Ruby/Linux/X64/utils/tcp_connection_data.rb