Module: WakeOnLan

Defined in:
lib/wake_on_lan.rb,
lib/wake_on_lan/version.rb

Defined Under Namespace

Classes: MagicPacket

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.wake(mac_address, broadcast, port) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/wake_on_lan.rb', line 9

def self.wake(mac_address, broadcast, port)
  packet = MagicPacket.new(mac_address).assemble_frame

  socket = UDPSocket.open()
  socket.setsockopt Socket::SOL_SOCKET, Socket::SO_BROADCAST, 1

  socket.send packet, 0, broadcast, port
  socket.close
end