Socket Server code - addressing bug fix
There’s a bug in one of the constructors for CSocket::InternetAddress
which means that changing the example servers to use a specific network adapter’s address, rather than INADDR_ANY
will generate an exception from the call to bind
which says that the address is invalid.
The code currently reads like this:
CSocket::InternetAddress::InternetAddress(
const unsigned long address,
const unsigned short port)
{
sin_family = AF_INET;
sin_port = htons(port);
sin_addr.s_addr = htonl(address);
}
and it should read like this:
CSocket::InternetAddress::InternetAddress(
const unsigned long address,
const unsigned short port)
{
sin_family = AF_INET;
sin_port = htons(port);
sin_addr.s_addr = address;
}
This bug only affects The Free Framework, that is, the code that’s freely available here on my blog (here) and doesn’t affect the licensed version of The Server Framework.