This is the reland of 127489 with fix on Mac. IPv6 and IPv4 behave differently in setsockopt(). IPv6 requires an index instead of an address. https://dart-review.googlesource.com/c/sdk/+/127489 Bug: https://github.com/dart-lang/sdk/issues/39691 Change-Id: Idc0449e88be47663851f2de90cdbbf3f13466221 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128367 Reviewed-by: Siva Annamalai <asiva@google.com> Commit-Queue: Zichang Guo <zichangguo@google.com>