0

Does anyone know if it's possible to send a magic packet using the WebSocket API ?

Edit:

As my question seamed unclear. I want to know I using the API with Javascript I could send the UDP-datagram needed send a wake-on-lan packet.

I know it's possible using php with socket enabled, but with JS ?

0

1 Answer 1

1

If you mean:

"Can I use JavaScript in browser to send a WebSocket message that makes a specific, given byte sequence appear on the wire?"

Then the answer is no. Reason: the WebSocket protocol requires all client-to-server protocol payload to be masked. And the mask is generated randomly in the WebSocket browser implementation, so you have no chance (by design) to choose mask or payload for the desired byte sequence to appear on the wire.

2
  • And as far as I understand, Wake-on-Lan also requires sending an Ethernet broadcast frame with specific contents (en.wikipedia.org/wiki/Wake-on-LAN#Magic_packet). Not sure, but it seems this is usually done via UDP broadcast (though I don't understand how that works given that an UDP packet != Ethernet frame). So you might as well restate your question: "Can I send an UDP broadcast package from JS in browser"? As far as I know only WebRTC involves UDP (for media transport), but I don't know if you can abuse it for UDP broadcasts - guess unlikely.
    – oberstet
    Oct 5, 2012 at 11:24
  • Actually, if i'm not wrong. A magic packet can be just a UDP-datagram sent to a rooter (so no broadcast) who then broadcast it to the network. And in the content of the datagram it's only 12 ff followed by 16 times the target MAC adress. Oct 5, 2012 at 17:24

Not the answer you're looking for? Browse other questions tagged or ask your own question.