@@ -513,11 +513,13 @@ fn test_sockopts_ipv6() {
513
513
#[ cfg( linux_kernel) ]
514
514
#[ test]
515
515
fn test_socketopts_ip_mtu ( ) {
516
+ use std:: net:: SocketAddrV4 ;
517
+
516
518
crate :: init ( ) ;
517
519
518
520
let s = rustix:: net:: socket ( AddressFamily :: INET , SocketType :: DGRAM , None ) . unwrap ( ) ;
519
- rustix:: net:: bind ( & s, & "127.0.0.1:0" . parse ( ) . unwrap ( ) ) . unwrap ( ) ;
520
- rustix:: net:: connect ( & s, & "127.0.0.1:0" . parse ( ) . unwrap ( ) ) . unwrap ( ) ;
521
+ rustix:: net:: bind ( & s, & SocketAddrV4 :: new ( Ipv4Addr :: LOCALHOST , 0 ) ) . unwrap ( ) ;
522
+ rustix:: net:: connect ( & s, & SocketAddrV4 :: new ( Ipv4Addr :: LOCALHOST , 0 ) ) . unwrap ( ) ;
521
523
match sockopt:: ip_mtu ( & s) {
522
524
Ok ( mtu) => {
523
525
assert ! ( mtu > 0 ) ;
@@ -532,11 +534,13 @@ fn test_socketopts_ip_mtu() {
532
534
#[ cfg( linux_kernel) ]
533
535
#[ test]
534
536
fn test_socketopts_ipv6_mtu ( ) {
537
+ use std:: net:: { Ipv6Addr , SocketAddrV6 } ;
538
+
535
539
crate :: init ( ) ;
536
540
537
541
let s = rustix:: net:: socket ( AddressFamily :: INET6 , SocketType :: DGRAM , None ) . unwrap ( ) ;
538
- rustix:: net:: bind ( & s, & "[::1]:0" . parse ( ) . unwrap ( ) ) . unwrap ( ) ;
539
- rustix:: net:: connect ( & s, & "[::1]:0" . parse ( ) . unwrap ( ) ) . unwrap ( ) ;
542
+ rustix:: net:: bind ( & s, & SocketAddrV6 :: new ( Ipv6Addr :: LOCALHOST , 0 , 0 , 0 ) ) . unwrap ( ) ;
543
+ rustix:: net:: connect ( & s, & SocketAddrV6 :: new ( Ipv6Addr :: LOCALHOST , 0 , 0 , 0 ) ) . unwrap ( ) ;
540
544
541
545
match sockopt:: ipv6_mtu ( & s) {
542
546
Ok ( mtu) => {
0 commit comments