The documentation specifically says that ntohl
's netlong
parameter is a 32-bit value:
netlong [in]
A 32-bit number in TCP/IP network byte order.
I have read that long and int are not the same i.e. long is not guaranteed to be 32 bits or the same size of an integer INT_MAX.
You're right -- in Standard C++ a long
is not guaranteed to be any particular size, except that it must be at least 32 bits.
However since we're talking about the endian conversion functions, we're talking about platform-specifics here. We need to drill down now in to what a long
is under Windows. And under Windows, a long is 32-bits:
LONG
A 32-bit signed integer. The range is –2147483648 through 2147483647 decimal. This type is declared in WinNT.h as follows:
typedef long LONG;