Correctly convert remote port bytecode to uint16 port number. (#321)
* Correctly convert remote port bytecode to uint16 port number. Copied the network_to_host_short function from the ASIO library to convert the remote port byte code to a uint16 number. * Switched from uint16_t to unsigned short to work in Windows * Updated missed uint16_t to unsigned short
This commit is contained in:
@ -278,4 +278,17 @@ namespace ix
|
||||
#endif
|
||||
}
|
||||
|
||||
// Convert network bytes to host bytes. Copied from the ASIO library
|
||||
unsigned short network_to_host_short(unsigned short value)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
unsigned char* value_p = reinterpret_cast<unsigned char*>(&value);
|
||||
unsigned short result = (static_cast<unsigned short>(value_p[0]) << 8)
|
||||
| static_cast<unsigned short>(value_p[1]);
|
||||
return result;
|
||||
#else // defined(_WIN32)
|
||||
return ntohs(value);
|
||||
#endif // defined(_WIN32)
|
||||
}
|
||||
|
||||
} // namespace ix
|
||||
|
Reference in New Issue
Block a user