This applies to any TCP server where family = AF_INET6 (so will accept both v4/v6 clients)
v4 or v6 clients can connect as expected, however family is always v6.
In particular it is a “mapped” v4 address in v6. For example:
0::FFFF:192.168.1.1
The given example code in the Digi NET+OS .chm help file will not work:
theChildFd = accept( theSocketFd, (struct sockaddr*)&theClientAddr, &theClientAddrLen );
if (theChildFd < 0) {
printf("Accept failed
");
return;
}
/* Check if the connection is IPv4 or IPv6 */
if (theClientAddr.ss_family == AF_INET) {
printf("the connection is IPv4
");
}
if (theClientAddr.ss_family == AF_INET6) {
printf("the connection is IPv6
");
}
Any hints?