NAME
POE::Component::WakeOnLAN - A POE Component to send packets to power on
computers.
VERSION
version 1.04
SYNOPSIS
use strict;
use warnings;
use Data::Dumper;
use POE;
use POE::Component::WakeOnLAN;
my $mac_address = '00:0a:e4:4b:b0:94';
POE::Session->create(
package_states => [
'main' => [qw(_start _response)],
],
);
$poe_kernel->run();
exit 0;
sub _start {
POE::Component::WakeOnLAN->wake_up(
macaddr => $mac_address,
event => '_response',
);
return;
}
sub _response {
print Dumper( $_[ARG0] );
return;
}
DESCRIPTION
POE::Component::WakeOnLAN is a POE component that sends wake-on-lan (AKA
magic) packets to turn on machines that are wake-on-lan capable.
It is based on the Net::Wake module by Clinton Wong.
CONSTRUCTOR
"wake_up"
Sends a wake-on-lan packet via UDP. Takes a number of parameters:
'macaddr', the MAC Address of the host to wake up, mandatory;
'event', the event handler in your session where the result should be sent, mandatory;
'address', the IP address of the host to wake up, defaults to 255.255.255.255;
'port', the UDP port to communicate with, defaults to 9;
'session', optional if the poco is spawned from within another session;
'options', a hashref of POE Session options to pass to the component;
Generally speaking, you should use a broadcast address for "address"
( the component defaults to using 255.255.255.255 if one is not
supplied ), Using the host's last known IP address is usually not
sufficient since the IP address may no longer be in the ARP cache.
If you wish to send a magic packet to a remote subnet, you can use a
variation of '192.168.0.255', given that you know the subnet mask to
generate the proper broadcast address.
The "session" parameter is only required if you wish the output
event to go to a different session than the calling session, or if
you have spawned the poco outside of a session.
You may pass through any arbitary parameters you like, though they
must be prefixed with an underscore to prevent future parameter
clashes. These will be returned to you in the resultant event
response.
The poco does it's work and will return the output event with the
result.
OUTPUT EVENT
This is generated by the poco. ARG0 will be a hash reference with the
following keys:
'macaddr', the MAC address that was specified, the poco strips ':';
'address', the IP address that was used;
'port', the UDP port that was used;
Plus an arbitary key/values that were passed.
SEE ALSO
POE
Net::Wake
AUTHOR
Chris Williams
COPYRIGHT AND LICENSE
This software is copyright (c) 2011 by Chris Williams and Clinton Wong.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.