Files
sdk/runtime
Martin Kustermann 931ec382d4 [io/gardening] Fix client address binding & fix standalone/io/socket_local_port_test
Various changes to the stanalone/io/socket_local_port_test:

  * Make server ports ephemeral: The test is testing client-side
    binding of address & port, the server part can use ephemeral ports.
    => This eliminates the issue of another process using the
       hard-coded port
  * Close sockets normally instead of using `Socket.destroy()`
  * Make dead code alive: There were test in the tests that were
    not invoked by `main()`.
  * Align the individual test helper functions.
  * ...

Then we change the dart:io implementation of `Socket::CreateBindConnect`
to set the `SO_REUSEADDR` socket option. We do this already for the
server side in `Socket::CreateBindListen`, now we do it also for the
client side.
=> This will ensure that one can bind the client side socket to
   specific address/source despite there being an old closed
   socket that's now in `TIME_WAIT` state.
=> This is the same reason we also do it in `Socket::CreateBindListen`.

Fuchsia doesn't implement `Socket::CreateBindConnect` and on Windows
the socket option seemingly has different semantics (we also don't use
`SO_REUSEADDR` on windows for the server socket, but another option).

Issue https://github.com/dart-lang/sdk/issues/51477

TEST=standalone/io/socket_local_port_test

Change-Id: I7d07becad0cd98c3a9b973ef2f9037730d3f8b19
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436902
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2025-06-25 02:56:21 -07:00
..
2025-06-23 21:08:19 -07:00