
I need this little tool to aid (mis)behaving HTPC's and the like. When they are switched on, I need them to send a wakeup call to my homeserver, but I need that to work only if there is a network up and running (ie. if there's no network they have to wait).
It would look something like this:
1. check if the network is up (probably simply checking for an allocated IP address would do, ie. once 0.0.0.0 has been replaced by something like 192.168.0.110 or something similar), this I know how to do (would be interesting to see if there's something to check if a wifi link is up, but that isn't required)
2. once up, send a WOL to a specific MAC address, if anyone would have a WOL sample code, I'd appreciate it (especially a PureBasic working one

3. ping the intended server, until it replies
Why this approach? Take a laptop that's abuses as HTPC, it first builds up a wifi link, and when that link is up the laptop gets it's network assigned IP address (DHCP, though I noticed that with some wifi adapters even a fixed IP is reported as 0.0.0.0 until the wifi link is connected). However, even if there is a local valid IP address, it sometimes takes another few seconds before you actually can send out a WOL or PING a server, so I guess I would do an intermediate WOL then PING then WOL then PING etc. until the server replies.
Now, put the above on-screen in a single program with a large window with a busy indicator, and life's suddenly good for the poort htpc crowd that uses a power saving server

I've looked around but couldn't find such an all in one tool, which is weird, but hey, if one can't find it, then it's time to make it.
It's probably doable with scripts / batch files etc. but it all gets so messy that way... Suggestions / solutions / links / samples / help anyone?