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.

Answered By – SupaMaggie70 b

Answer Checked By – Willingham (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published.