Sample code for 30+ languages & platforms
PowerBuilder

Send a Wake-on-LAN Magic Packet

See more Socket/SSL/TLS Examples

Demonstrates Socket.SendWakeOnLan, which sends a Wake-on-LAN magic packet for a MAC address to a UDP broadcast address and port.

Background. The MAC address is six bytes written as hexadecimal. Wake-on-LAN wakes a powered-down machine on the local network that has the feature enabled.

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Socket

li_Success = 0

loo_Socket = create oleobject
li_rc = loo_Socket.ConnectToNewObject("Chilkat.Socket")
if li_rc < 0 then
    destroy loo_Socket
    MessageBox("Error","Connecting to COM object failed")
    return
end if

//  Send a Wake-on-LAN magic packet to wake a machine by its MAC address.  The MAC is six bytes
//  written as hexadecimal, and the packet is sent to the UDP broadcast address and port.
li_Success = loo_Socket.SendWakeOnLan("000102030405",9,"255.255.255.255")
if li_Success = 0 then
    Write-Debug loo_Socket.LastErrorText
    destroy loo_Socket
    return
end if

Write-Debug "Wake-on-LAN packet sent."


destroy loo_Socket