Class: Socket

Inherits:
Object show all
Defined in:
lib/openc3/core_ext/socket.rb

Overview

OpenC3 specific additions to the Ruby Socket class

Constant Summary collapse

IP_MULTICAST_IF =

Define needed constants for Windows

9
IP_MULTICAST_TTL =
10

Class Method Summary collapse

Class Method Details

.get_own_ip_addressString

Returns The IP address of the current machine.

Returns:

  • (String)

    The IP address of the current machine



29
30
31
# File 'lib/openc3/core_ext/socket.rb', line 29

def self.get_own_ip_address
  Resolv.getaddress Socket.gethostname
end

.lookup_hostname_from_ip(ip_address) ⇒ String

Returns The hostname of the given IP address or ‘UNKNOWN’ if the lookup fails.

Parameters:

  • ip_address (String)

    IP address in the form xxx.xxx.xxx.xxx

Returns:

  • (String)

    The hostname of the given IP address or 'UNKNOWN' if the lookup fails



36
37
38
39
40
# File 'lib/openc3/core_ext/socket.rb', line 36

def self.lookup_hostname_from_ip(ip_address)
  return Resolv.getname(ip_address)
rescue
  return 'UNKNOWN'
end