Windows 10: getaddrinfo - connect UDP IPv6 to IPv4

Discus and support getaddrinfo - connect UDP IPv6 to IPv4 in Windows 10 Network and Sharing to solve the problem; Hi there, I tried to connect a local IPv6 UDP socket to a remote IPv4 IP, as follows: #include <stdio.h> #include <stdlib.h> #include <string.h>... Discussion in 'Windows 10 Network and Sharing' started by JohannesWilde, Aug 19, 2020.

  1. getaddrinfo - connect UDP IPv6 to IPv4


    Hi there,


    I tried to connect a local IPv6 UDP socket to a remote IPv4 IP, as follows:


    #include <stdio.h>

    #include <stdlib.h>

    #include <string.h>

    #include <errno.h>

    #include <iostream>



    #include <winsock2.h>

    #include <Ws2tcpip.h>

    #include <io.h>





    int getUdpAddrInfo_const std::string &ip, const std::string &port, addrinfo **result

    {

    struct addrinfo hints;

    memset&hints, 0, sizeofstruct addrinfo;

    hints.ai_socktype = SOCK_DGRAM; /* Datagram socket */

    hints.ai_family = AF_UNSPEC; /* Allow IPv4 and IPv6 */

    // For Linux and Windows Vista onwards, further specify options

    hints.ai_flags = AI_V4MAPPED AI_ALL AI_ADDRCONFIG; /* For wildcard IP address */

    hints.ai_protocol = IPPROTO_UDP; /* UDP protocol */

    hints.ai_canonname = NULL;

    hints.ai_addr = NULL;

    hints.ai_next = NULL;



    int const s = getaddrinfo

    /* ip */ ip.data,

    /* port */ port.data,

    /* hints */ &hints,

    /* list */ result;

    return s;

    }





    int main int argc, char *argv[]

    {

    WORD wVersionRequested = MAKEWORD2, 2;

    WSADATA wsaData;

    int const wsaStartupStatus = WSAStartupwVersionRequested, &wsaData;



    std::string const ipLocal"::";

    std::string const portLocal"1234";



    std::string const ipRemote"127.0.0.1";

    std::string const portRemote"2345";



    struct addrinfo *result;

    int s = getUdpAddrInfo_ipLocal, portLocal, &result;

    if s != 0

    {

    exit1;

    }



    SOCKET connectedSocket = INVALID_SOCKET;

    if nullptr == result

    {

    exit1;

    }



    struct addrinfo *rp = nullptr;

    for rp = result; rp != NULL; rp = rp->ai_next

    {

    SOCKET sock = socketrp->ai_family,

    rp->ai_socktype,

    rp->ai_protocol;



    if INVALID_SOCKET == sock

    {

    continue;

    }

    else

    {

    if AF_INET6 == rp->ai_family

    {

    DWORD const ipv6Only = 0; // 0 - false

    int const errorCode = setsockoptsock, IPPROTO_IPV6, IPV6_V6ONLY, char const *&ipv6Only, sizeofipv6Only;

    if NO_ERROR != errorCode

    {

    exit1;

    }

    }

    if bindsock, rp->ai_addr, rp->ai_addrlen == NO_ERROR

    {



    // connect

    struct addrinfo *result2;

    int const s2 = getUdpAddrInfo_ipRemote, portRemote, &result2; // 1

    if s2 != 0

    {

    exit1;

    }



    struct addrinfo *rp2 = nullptr;

    bool connected = false;

    if result2

    {

    for rp2 = result2; rp2 != NULL; rp2 = rp2->ai_next

    {

    if connectsock, rp2->ai_addr, rp2->ai_addrlen == NO_ERROR

    {

    connected = true;

    break;

    }

    }

    }

    freeaddrinforesult2;





    if connected

    {

    connectedSocket = sock;

    break;

    }

    }

    else

    {

    closesocketsock;

    }

    }

    }



    freeaddrinforesult; /* No longer needed */



    std::cout << "socket: " << connectedSocket << std::endl;



    closesocketconnectedSocket;



    WSACleanup;



    exit0;

    }


    The getUdpAddrInfo_ at 1 however only returns an IPv4 and no IPv6-mapped IPv4 address.


    If I instead set


    hints.ai_family = AF_INET6;



    then the IPv4-mapped IPv6 address is returned as desired. Do I have to explicitely check what kind of socket I want to connect and ask for an appropriate address? Why does it not return the IPv6-mapped IPv4 address?


    Best regards,


    Johannes

    :)
     
    JohannesWilde, Aug 19, 2020
    #1

  2. Connectivity (IPv4/IPv6): Disconnected

    Hi,



    Thank you for writing to Microsoft Community Forums.



    Ideally this Connectivity (IPv4/IPv6): Disconnected, means that the devices in not in use or not connected and it could be any device for example, Ethernet, WIFI, Bluetooth or Local Area Connection.



    If you are using WI-FI for internet connection then Ethernet will show Connectivity (IPv4/IPv6): Disconnected.



    In order to understand the issue and assist you accordingly, we need some information

    • What is your network setup?
    • Are you seeing any errors?
    • Where you are seeing this information?


    Meanwhile, try the troubleshooting steps referred in this article:

    Fix network connection issues in Windows
    and check if it works.



    Regards,

    Aditya Roy

    Microsoft Community – Moderator
     
    Aditya_Roy, Aug 19, 2020
    #2
  3. philness Win User
    ipv4 connected ipv6 no network access

    So I thought my problem was solved, and then just now my internet stopped working again. Same problem, ipv4 connected ipv6 no network access. Anyone have any suggestions?
     
    philness, Aug 19, 2020
    #3
  4. getaddrinfo - connect UDP IPv6 to IPv4

    Connectivity (IPv4/IPv6): Disconnected

    Name: Ethernet

    Description: Realtek PCIe GBE Family Controller

    Physical address (MAC): ec:8e:b5:d6:e4:0b

    Status: Not operational

    Maximum transmission unit: 1500

    IPv4 address: 169.254.250.35/16

    IPv6 address: fe80::8408:262a:dd06:fa23%12/64

    DNS servers: 192.168.1.254, 75.153.171.122

    DNS connection suffix: telus

    Connectivity (IPv4/IPv6): Disconnected





    Name: Wi-Fi

    Description: Realtek RTL8723BE 802.11 bgn Wi-Fi Adapter

    Physical address (MAC): cc:b0:da:45:99:2b

    Status: Not operational

    Maximum transmission unit: 1500

    IPv4 address: 169.254.90.214/16

    IPv6 address: fe80::853f:94b6:aeb2:5ad6%15/64

    DNS servers: 192.168.43.1

    Connectivity (IPv4/IPv6): Disconnected





    Name: Local Area Connection* 12

    Description: Microsoft Hosted Network Virtual Adapter

    Physical address (MAC): 48:f8:b3:97:96:cb

    Status: Not operational

    Maximum transmission unit: 1500

    IPv4 address: 169.254.184.142/16

    IPv6 address: fe80::a415:bde6:5709:b88e%20/64

    DNS servers: fec0:0:0:ffff::1%1, fec0:0:0:ffff::2%1, fec0:0:0:ffff::3%1

    Connectivity (IPv4/IPv6): Disconnected





    Name: Wi-Fi 2

    Description: Linksys AE1200

    Physical address (MAC): 48:f8:b3:97:96:cb

    Status: Operational

    Maximum transmission unit: 1500

    Link speed (Receive/Transmit): 144/104 (Mbps)

    DHCP enabled: Yes

    DHCP servers: 192.168.1.254

    DHCP lease obtained: ‎November ‎1, ‎2018 4:03:27 PM

    DHCP lease expires: ‎November ‎2, ‎2018 4:03:27 PM

    IPv4 address: 192.168.1.67/24

    IPv6 address: 2001:56a:f2d7:3800:29ed:7176:fa4f:7afa/64, 2001:56a:f2d7:3800:a588:1afb:4da:872e/128, fe80::29ed:7176:fa4f:7afa%3/64

    Default gateway: fe80::72f1:96ff:fe5c:2dd0%3, 192.168.1.254

    DNS servers: 2001:568:ff09:10c::53, 2001:568:ff09:10b::122, 192.168.1.254, 75.153.171.122

    DNS domain name: telus

    DNS connection suffix: telus

    DNS search suffix list:

    Network name: TELUS4370

    Network category: Private

    Connectivity (IPv4/IPv6): Connected to Internet





    Name: Bluetooth Network Connection

    Description: Bluetooth Device (Personal Area Network)

    Physical address (MAC): cc:b0:da:45:99:2c

    Status: Not Present

    Maximum transmission unit: 0

    Connectivity (IPv4/IPv6): Disconnected





    Name: Local Area Connection* 10

    Description: Microsoft Wi-Fi Direct Virtual Adapter

    Physical address (MAC): ce:b0:da:45:99:2b

    Status: Not Present

    Maximum transmission unit: 0

    Connectivity (IPv4/IPv6): Disconnected





    Name: Local Area Connection* 11

    Description: Microsoft Wi-Fi Direct Virtual Adapter #2

    Physical address (MAC): cc:b0:da:45:99:2b

    Status: Not Present

    Maximum transmission unit: 0

    Connectivity (IPv4/IPv6): Disconnected
     
    Florence W10, Aug 19, 2020
    #4
Thema:

getaddrinfo - connect UDP IPv6 to IPv4

Loading...
  1. getaddrinfo - connect UDP IPv6 to IPv4 - Similar Threads - getaddrinfo connect UDP

  2. Connectivity IPv4/IPv6: Disconnected

    in Windows 10 Gaming
    Connectivity IPv4/IPv6: Disconnected: No connection to Internet, no connection icon appeared. https://answers.microsoft.com/en-us/windows/forum/all/connectivity-ipv4ipv6-disconnected/275ba775-dfca-4721-9d5a-671d3773d4b7
  3. Connectivity IPv4/IPv6: Disconnected

    in Windows 10 Software and Apps
    Connectivity IPv4/IPv6: Disconnected: No connection to Internet, no connection icon appeared. https://answers.microsoft.com/en-us/windows/forum/all/connectivity-ipv4ipv6-disconnected/275ba775-dfca-4721-9d5a-671d3773d4b7
  4. Connectivity IPv4/IPv6: Disconnected

    in Windows 10 Network and Sharing
    Connectivity IPv4/IPv6: Disconnected: No connection to Internet, no connection icon appeared. https://answers.microsoft.com/en-us/windows/forum/all/connectivity-ipv4ipv6-disconnected/275ba775-dfca-4721-9d5a-671d3773d4b7
  5. Connectivity IPv4/IPv6: Disconnected

    in Windows 10 Software and Apps
    Connectivity IPv4/IPv6: Disconnected: Name: EthernetDescription: Realtek PCIe GbE Family ControllerPhysical address MAC: 9c:7b:ef:20:8e:79Status: Not operationalMaximum transmission unit: 1500IPv4 address: 169.254.172.34/16IPv6 address: fe80::7899:cb42:47f:280a%8/64DNS servers: fec0:0:0:ffff::1%1,...
  6. Connectivity IPv4/IPv6: Disconnected

    in Windows 10 Gaming
    Connectivity IPv4/IPv6: Disconnected: Name: EthernetDescription: Realtek PCIe GbE Family ControllerPhysical address MAC: 9c:7b:ef:20:8e:79Status: Not operationalMaximum transmission unit: 1500IPv4 address: 169.254.172.34/16IPv6 address: fe80::7899:cb42:47f:280a%8/64DNS servers: fec0:0:0:ffff::1%1,...
  7. Connectivity IPv4/IPv6: Disconnected

    in Windows 10 Drivers and Hardware
    Connectivity IPv4/IPv6: Disconnected: Name: EthernetDescription: Realtek PCIe GbE Family ControllerPhysical address MAC: 9c:7b:ef:20:8e:79Status: Not operationalMaximum transmission unit: 1500IPv4 address: 169.254.172.34/16IPv6 address: fe80::7899:cb42:47f:280a%8/64DNS servers: fec0:0:0:ffff::1%1,...
  8. IPv6 connectivity is dropping but not IPv4

    in Windows 10 Network and Sharing
    IPv6 connectivity is dropping but not IPv4: I work with many open SSH sessions at least six using tmux. After a few hours, the sessions to IPv6 addresses are dropping. The ones to IPv4 are not. I am able to confirm that I have lost all IPv6 connectivity using the site https://test-ipv6.com/ Using ipConfig, I see...
  9. Connectivity IPv4/IPv6: Disconnected

    in Windows 10 Network and Sharing
    Connectivity IPv4/IPv6: Disconnected: when i look at my network properties it says this: Connectivity IPv4/IPv6: Disconnected. What does mean? ***Original Title: when i look at my network properties it says this: Connectivity IPv4/IPv6: Disconnected. What does mean?***...
  10. IPv4 and IPv6 Connectivity?

    in Windows 10 Network and Sharing
    IPv4 and IPv6 Connectivity?: Hi, I did a clean install of my Win10 Home about a week ago and it all turned out for the good. However, tonight while nosing around my Network Connections I notice I am connected to the Internet by Ethernet (Realtek PCle GBF Family Controller) which I thought I was since...