Class: Socket

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

Class Method Summary collapse

Class Method Details

.if_nametoindex(name) ⇒ Object


2
3
4
5
6
# File 'lib/core/core_ext/socket.rb', line 2

def self.if_nametoindex(name)
  ifaddr_by_name(name).ifindex
rescue NoMethodError
  0
end

.if_up?(name) ⇒ Boolean


8
9
10
11
12
# File 'lib/core/core_ext/socket.rb', line 8

def self.if_up?(name)
  ifaddr_by_name(name).flags & Socket::IFF_UP == 1
rescue NoMethodError
  false
end