Skip to content

Instantly share code, notes, and snippets.

@ghisguth
Created May 30, 2009 19:49
Show Gist options
  • Save ghisguth/120615 to your computer and use it in GitHub Desktop.
Save ghisguth/120615 to your computer and use it in GitHub Desktop.
signed long my_signed_htonl(signed long value)
{
unsigned long l = *reinterpret_cast<unsigned long *>(&value);
l = htonl(l);
return *reinterpret_cast<signed long *>(&l);
}
signed long my_signed_ntohl(signed long value)
{
unsigned long l = *reinterpret_cast<unsigned long *>(&value);
l = ntohl(l);
return *reinterpret_cast<signed long *>(&l);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment