1 min read

Epic Microsoft Fail --- Sockets

Alright everyone, fairing warning, here comes the rant.

Whose brilliant idea was it to switch the order of the fields in the struct addrinfo structure used by all sorts of Sockets programs? I mean, WTF? This is one of those things that I just don't get at all. It's really quite simple, actually, use the same friggin' field order! I can understand if maybe they needed to add some new features or something, and even then, it's not so hard to add it to the end of the structure, but why on earth would you swap them??? Here's my point illustrated in horrid detail:

On UNIX-like machines, the struct addrinfo structure generally looks something like this:

struct addrinfo {
        int              ai_flags;
        int              ai_family;
        int              ai_socktype;
        int              ai_protocol;
        size_t           ai_addrlen;
        struct sockaddr *ai_addr;
        char            *ai_canonname;
        struct addrinfo *ai_next;
};


That's easy enough, right? Now take a look at what Microsoft gives us:

struct addrinfo {
        int              ai_flags;
        int              ai_family;
        int              ai_socktype;
        int              ai_protocol;
        size_t           ai_addrlen;
        char            *ai_canonname;
        struct sockaddr *ai_addr;
        struct addrinfo *ai_next;
};


Did you catch the difference there? Did you? You have to look closely to see it, and you would only see it if you were actually relying on the order, which I actually happen to be relying on in some code (stupid me). I should probably rewrite my code so that it is not sensitive to this sort of problem, but why oh why should I have to do that? Why would you change something so simple to keep the same????

Gah. It makes me rather annoyed.