Comment

Comment by greenyoda

I don't understand how this code in client.c works:

    char filler[16] = {0};
    ...
    filler[0] = (unsigned short)AF_INET;
    filler[2] = (unsigned short)htons(port);
    filler[4] = (unsigned long)htonl(INADDR_ANY);
In C, sizeof(char) is one byte. Since htons() returns a short (the port number in network order), wouldn't you get an overflow and lose data when you assign it to filler[2]?

(And similarly for filler[4].)

parent greenyoda 11 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton