웹마스터 팁

PHP 메뉴얼에서 소켓관련 함수 찾다가 발견한건데
기능구현이 되는지는 아직확인을 못해봤군요
ㅋㅋㅋ
별게 다 되는 군여..
---------
function WakeOnLan($addr, $mac) { # (C)opyright 2K2 hotkey@spr.at
$addr_byte = explode(':', $mac);
$hw_addr = '';
for ($a=0; $a < 6; $a++) $hw_addr .= chr(hexdec($addr_byte[$a]));

$msg = chr(255).chr(255).chr(255).chr(255).chr(255).chr(255);
for ($a = 1; $a <= 16; $a++) $msg .= $hw_addr;
# send it to the broadcast address using UDP
$s = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
if ($s == false) {
   echo "Error creating socket!n";
   echo "Error:".socket_strerror(socket_last_error($s));
} else {
   $e = socket_connect($s, $addr, 2050);
   if ($e == false) {
     echo "connection failedn";
     echo "Error:".socket_strerror(socket_last_error($s));
   } else {
     $e = socket_setopt($s, SOL_SOCKET, SO_BROADCAST, 1);
     $e = socket_write($s, $msg, strlen($msg));
     socket_close($s);

     echo "Magic Packet sent (".$e.") to ".$addr.", MAC=".$mac;
   }
}
}
WakeOnLan('255.255.255.255', 'MAC:MAC:MAC:MAC:MAC:MAC'); #put the MAC-to-be-woken here!
# IP must be 255.255.255.255 - at least it didnt work otherwise...