You should check what the other end is expecting (i.e. maybe the other end is expecting little-endian numbers, in which case everybody's happy, although that's not all that likely). If you need to convert to big-endian, then there is htons (since "network order" is another name for "big-endian").