dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.11k stars 1.56k forks source link

Fix the behavior of `Socket.address` #50576

Open brianquinlan opened 1 year ago

brianquinlan commented 1 year ago

Change

Socket.address currently returns the same InternetAddress as Socket.remoteAddress. Instead, it should return the local address that the Socket was bound to.

The original bug is: dart:io, address getter of Socket returns wrong address.

Rationale

The current behavior is not useful. Instead, two connected sockets should have a relationship like:

Expect.equals(clientSocket.address, serverSocket.remoteAddress);
Expect.equals(clientSocket.remoteAddress, serverSocket.address);

There is a work-in-progress change in Gerrit.

Impact

It is hard to know how much existing code this will break. It does not break any Google tests and I would guess that it does not break much existing code.

Mitigation

Users can switch their code to use Socket.remoteAddress instead of Socket.address if they want the remote socket binding.

itsjustkevin commented 1 year ago

@vsmenon @Hixie @grouma we have another breaking change request. Could you take a look?

grouma commented 1 year ago

Since there is an easy mitigation and no broken Google tests this is probably fine. I do have concerns that some of our developer tools that historically don't have great test coverage could be broken. For example, Dart Dev Runner, Bolt, package:webdev etc.

Hixie commented 1 year ago

SGTM. Might be worth looking at https://github.com/dart-lang/sdk/issues/12693 at the same time.

brianquinlan commented 1 year ago

Ah, I noticed #12693 as well. I think that fixing just that part might be non-breaking but I'll take a look.

vsmenon commented 1 year ago

lgtm

itsjustkevin commented 1 year ago

Marking this as approved.

itsjustkevin commented 1 year ago

@brianquinlan is this work still in flight? Is it planned for Dart 3?

BBUBBA commented 4 days ago

The bug that happened in 2019, still hasn't been fixed..

Can't P2P UDP HolePunch.

plz.. Update. Thank you !!!