Why are SocketAddrV4/SocketAddrV6 based on low level sockaddr_in[6]?

The benchmarks above only benchmark converting SocketAddr -> c::sockaddr and not the other way around. I realized that UdpSocket::local_addr() is a call that does the conversion the other way, and it also does not involve any network traffic.

Similar results. No measurable change in performance. Around ~500 ns both with the current standard library and the code in my PR:

UdpSocket::local_addr (v4)                                                                             
                        time:   [525.15 ns 527.26 ns 529.65 ns]
                        change: [-0.2401% +0.7189% +1.6319%] (p = 0.14 > 0.05)
                        No change in performance detected.
Found 7 outliers among 100 measurements (7.00%)
  4 (4.00%) high mild
  3 (3.00%) high severe

UdpSocket::local_addr (v6)                                                                             
                        time:   [537.96 ns 540.84 ns 544.13 ns]
                        change: [+0.6489% +1.3014% +1.9054%] (p = 0.00 < 0.05)
                        Change within noise threshold.
Found 4 outliers among 100 measurements (4.00%)
  2 (2.00%) high mild
  2 (2.00%) high severe
1 Like