简体   繁体   中英

Flutter: How can I use both IPv4 and IPv6 addresses with my client?

I have a server where I need to connect. My client is written in Dart, and binds the socket like this:

static Future<RawDatagramSocket> rDgS =
      RawDatagramSocket.bind(InternetAddress.anyIPv4, 50943);

Can I use something else to not specify the version of the IP-protocol to make it connect on both IPv4 and IPv6-only.networks? I am using UDP sockets.

I have tried both anyIPv4 and andIPv6 using both server IP-addresses (IPv4 and IPv6) since I don't have a DNS hostname for my server. Only anyIPv4 works with IPv4 address.

To accept IPv6 connections, you have to have a IPv6 address. Same for accepting IPv4. Similarly, to connect, you both have to be using the same protocol. IPv4 and IPv6 are not interchangeable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM