Auto-updating software
So, over the years, I’ve released a few programs (all native C/C++) which have included automatic version checking, so they can let the user know when a new version is available. I’ve always done this by making a socket connection to my web server (previously Apache, now entirely Node.js) and asking for a file which just contains a version number. Pretty simple, right? Sure!
SOCKET s = socket(AF_INET, SOCK_STREAM, 0); connect(s, ...); char cmd[] = "GET http://www.bigscreensmallgames.com/BestBombermanEver/version.txt HTTP/1.0\r\n\r\n"; send(s, cmd, sizeof(cmd), 0); recv(s, ...);
And that’s about it. Note:
- This sends a single packet, and no router’s MTU is small enough that this packet would ever be fragmented, so it is, in theory, at least according to how TCP/IP is supposed to work, guaranteed to arrive as a single packet. Not that most web servers would care…
- I don’t bother sending any headers, specifically the Host header. Why would I if this works?
- There’s a bug in the code, it’s writing the NULL character into the packet after the final line feed.
Continue reading “The horrible things people’s routers do to my packets!”