I have a C++ application that uses the same IPv6 UDP socket to send to IPv6 or IPv4 destinations.
sockfd = socket(PF_INET6, SOCK_DGRAM, 0);
dest_addr.sin6_family = AF_INET;
dest_addr.sin6_port = htons(dest_port);
inet_pton ("192.168.1.33", &dest_addr.sin6_addr);
sendto (sockfd, message, strlen(message)+1, 0, (struct sockaddr *)&dest_addr, sizeof(struct sockaddr_in6));
On Linux this works fine, but on FreeBSD I get an error Address family not supported by protocol family
when I send to IPv4 addresses.
Is there a way to configure FreeBSD to accept this?
Maybe similar to ipv6_ipv4mapping="YES"
for listening to IPv4 clients?
(sockaddr *)
, not(struct sockaddr *)
- phuclv