#include // for htonl #include // for bswap32 #include // for uint32_t uint32_t htonl(uint32_t hostlong) { union { int i; char c; } u = { 1 }; return u.c ? bswap32(hostlong) : hostlong; }