Breaking change 50576: Fix the behavior of Socket.address

93 views
Skip to first unread message

Brian Quinlan

unread,
Nov 29, 2022, 12:26:15 PM11/29/22
to anno...@dartlang.org
See discussion on breaking change: https://github.com/dart-lang/sdk/issues/50576

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.


Reply all
Reply to author
Forward
0 new messages