Class: Socket
Overview
COSMOS 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
-
.get_own_ip_address ⇒ String
The IP address of the current machine.
-
.lookup_hostname_from_ip(ip_address) ⇒ String
The hostname of the given IP address or ‘UNKNOWN’ if the lookup fails.
Class Method Details
.get_own_ip_address ⇒ String
Returns The IP address of the current machine.
26 27 28 |
# File 'lib/cosmos/core_ext/socket.rb', line 26 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.
33 34 35 36 37 |
# File 'lib/cosmos/core_ext/socket.rb', line 33 def self.lookup_hostname_from_ip(ip_address) return Resolv.getname(ip_address) rescue return 'UNKNOWN' end |