Sha256: 2aeb282b99f9bd6afc4a8a97a7b90f2e31cd7731ab31205505a70fab6c14f6f7

Contents?: true

Size: 834 Bytes

Versions: 6

Compression:

Stored size: 834 Bytes

Contents

module RubySL
  module Socket
    module Foreign
      class Hostent < Rubinius::FFI::Struct
        config('rbx.platform.hostent', :h_name, :h_aliases, :h_addrtype,
               :h_length, :h_addr_list)

        def hostname
          self[:h_name]
        end

        def type
          self[:h_addrtype]
        end

        def aliases
          return [] unless self[:h_aliases]

          RubySL::Socket::Foreign.pointers_of_type(self[:h_aliases], :string)
            .map(&:read_string)
        end

        def addresses
          return [] unless self[:h_addr_list]

          RubySL::Socket::Foreign.pointers_of_type(self[:h_addr_list], :string)
            .map { |pointer| pointer.read_string(self[:h_length]) }
        end

        def to_s
          pointer.read_string(size)
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rubysl-socket-2.2.1 lib/rubysl/socket/foreign/hostent.rb
rubysl-socket-2.2 lib/rubysl/socket/foreign/hostent.rb
rubysl-socket-2.1.3 lib/rubysl/socket/foreign/hostent.rb
rubysl-socket-2.1.2 lib/rubysl/socket/foreign/hostent.rb
rubysl-socket-2.1.1 lib/rubysl/socket/foreign/hostent.rb
rubysl-socket-2.1.0 lib/rubysl/socket/foreign/hostent.rb