Skip to main content

SendMagicPacket

Trait SendMagicPacket 

Source
pub trait SendMagicPacket {
    // Required method
    fn send_magic_packet<A: ToSocketAddrs>(
        &self,
        mac_address: MacAddress,
        secure_on: Option<SecureOn>,
        addr: A,
    ) -> Result<()>;
}
Expand description

A socket which supports sending a magic packet.

Required Methods§

Source

fn send_magic_packet<A: ToSocketAddrs>( &self, mac_address: MacAddress, secure_on: Option<SecureOn>, addr: A, ) -> Result<()>

Send a magic packet over this socket.

Send a magic packet to wake up mac_address over this socket. If secure_on is not None, include the SecureON token in the packet. Use addr as destination address for the packet.

§SecureON

In addition to the mac_address, you can optionally include a shared “SecureON” token in the magic packet.

See SecureOn for more information.

§Target address

Normally, you would send the packet to the broadcast address (IPv4) or the link-local multicast address (IPv6), but you may specify any address as long as the target host will physically see the packet along its way to the target address.

Any target port will do, since the magic packet never makes it to the operating system where ports matter; the NIC will directly process it.

Port 9 (discard) is often a good choice, because no service will listen on this port.

§Errors

Return any errors from the underlying socket I/O.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl SendMagicPacket for UdpSocket

Source§

fn send_magic_packet<A: ToSocketAddrs>( &self, mac_address: MacAddress, secure_on: Option<SecureOn>, addr: A, ) -> Result<()>

Implementors§