This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Simple Wake-on-lan
#1
Hello,

The wake-on-lan code I am using.

Code:
--[[ Librairy : Wake-on-lan
Author : Matthieu Bouthors

Use with mac address
example : WOL("4c-cc-6a-03-55-eb")

Reminder : only works if the destination is on the same subnet, not routable
]]--

function WOL(target)

 local socket = require("socket")
 local dest_ip="255.255.255.255"
 local port=9
 local udp = assert(socket.udp())
 udp:setoption('broadcast', true)
 
 clean_target = string.gsub(target,":","")
 clean_target = string.gsub(clean_target,"-","")

 hex_target = lmcore.hextostr(clean_target)

 payload = lmcore.hextostr("FFFFFFFFFFFF")
 for i=1,16 do
   payload = payload .. hex_target
 end
 
 assert(udp:sendto(payload, dest_ip, port))

end

Matt
Reply


Messages In This Thread
Simple Wake-on-lan - by Matt - 19.06.2017, 20:35
RE: Simple Wake-on-lan - by leonidas - 21.06.2017, 08:40

Forum Jump: