Class: Memopri::Finder

Inherits:
Object
  • Object
show all
Defined in:
lib/memopri/finder.rb

Class Method Summary collapse

Class Method Details

.findObject



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/memopri/finder.rb', line 5

def self.find
  sendsocket = UDPSocket.new()
  recvsocket = UDPSocket.new()
  recvsocket.bind("0.0.0.0", 49168)
  sendsocket.setsockopt(Socket::SOL_SOCKET, Socket::SO_BROADCAST, true)
  recvsocket.setsockopt(Socket::SOL_SOCKET, Socket::SO_BROADCAST, true)

  sendsocket.connect("255.255.255.255", 49167)
  sendsocket.send("MEP r2", 0)
  return [recvsocket.recvfrom(47)]
end