I also mentioned an unrelated C++ program. Here it is! I’ve shared it before, but didn’t say much about how it came to be.
First, some background. I have three computers: a Linux laptop (specifically, a ThinkPad, because of course), a Mac laptop, and a Windows desktop. Typically, the Windows desktop serves as a gaming rig, but it also doubles as a file server. There are times when I need to pull things off the server on either of the laptops, but the Windows desktop is asleep. I could just walk over to it and wake it up, but no, that would take too much effort. So I enabled wake-on-LAN on the Windows desktop and wrote a tiny shell script on my Linux laptop that runs `wol` with my desktop’s MAC address pre-filled. The `wol` utility is available in most Linux package repositories, and Arch is no exception. All it takes is `sudo pacman -S wol` to grab it.
Turns out it’s not so easy on macOS. There’s a variant on Homebrew, but it works differently. It makes specifying a broadcast IP address and port mandatory, which I found kinda odd. So I turned to MacPorts, but it turns out their `wol` port is broken. I tried downloading the tarball and compiling it myself, but that was also broken.
Remember, I could just walk over to the desktop and wake it manually. But no, I decided this was a good opportunity to write my own `wol` implementation, because that would be easier?
To be fair, I didn’t write it from scratch. Instead, I cherry-picked pieces of two existing C++ implementations and glued them together. The “gluing together” part forced me to actually learn the language and what the code did. The experience also taught me about build systems. Long story short, they all suck, and some suck more than others. Right now I’m using CMake, but I’m considering going back to using plain old make directly. CMake is kind of a lot, and overkill for this project.
If possible, you should probably use an older and more established `wol` implementation. But if you wanna give my version a go, feel free!
https://github.com/digichelle/wol
#programming #CPlusPlus