The Ethernet library dearly needs a way to send packets without connecting a Client.
I would specifically want to send Wake-On-LAN magic packets - a UDP datagram would work just fine, but there's currently no high-level way to send anything to remote hosts that obviously aren't there to respond...
Thanks for the hint - looks pretty straightforward, unfortunately it seems to consume resources and might not fit into my already crammed application...
I'll probably need to try it as a proof of concept anyway, I will then post the code
OK - I actually didn't use any of that UDP wrapper code, since all it does is wrap... The minimal code to send a WOL packet, assuming we live in subnet 10.0.0.x/24:
/* Use 9999 as source port, shouldn't be of any relevance */
socket(socket_index, Sn_MR_UDP, 9999, 0);
/* Magic packet is 6 * 0xff followed by 16 times the destination MAC */
p = txbuf;
for(n = 0; n < 6; n++) p++ = 0xff;
for(n = 0; n < 16; n++) {
for(i = 0; i < 6; i++) p++ = remote_mac;
}* /* Send to remote_ip and port 0 (port doesn't matter) / sendto(socket_index, txbuf, 6 + 616, remote_ip, 9999);
close(socket_index);*
for(;;);* } The sad part here is that this can't really coexist with the normal Ethernet code during the time it is actually used, since we run over it - e.g. Server.begin() allocates all of the four sockets W5100 offers us, and so socket 0 used above is not free anymore then. That UDP example code linked previously in this topic has the same problem, though. I only tested this with one remote, and for some peculiar reason it really needed this packet to be sent to the broadcast IP address. As far as I understand, it should not matter since the NIC - which does all the work while the host system sleeps - doesn't even know its IP address when it receives the WOL packet.
Yes, you're right - but for some reason the helper program I've used to send WOL packets (wolcmd.exe) worked just fine using a single IP as destination address. I guess it sets the broadcast bit anyway.
But still, I would like to see further development on the Ethernet library, it's quite rudimentary as it is now (how do you shut down a server, for example?) But I guess this is a hard task, it uses a large part of the sketch space already...