@@ -554,6 +554,46 @@ impl TcpStream {
554
554
self . 0 . ttl ( )
555
555
}
556
556
557
+ /// Sets the value for the `IPV6_UNICAST_HOPS` option on this socket.
558
+ ///
559
+ /// This value sets the unicast hop limit field that is used in every packet
560
+ /// sent from this socket.
561
+ ///
562
+ /// # Examples
563
+ ///
564
+ /// ```no_run
565
+ /// #![feature(ipv6_hop_limit)]
566
+ /// use std::net::TcpStream;
567
+ ///
568
+ /// let stream = TcpStream::connect("[::1]:12345")
569
+ /// .expect("Couldn't connect to the server...");
570
+ /// stream.set_hop_limit_v6(88).expect("set_hop_limit_v6 call failed");
571
+ /// ```
572
+ #[ unstable( feature = "ipv6_hop_limit" , issue = "139166" ) ]
573
+ pub fn set_hop_limit_v6 ( & self , limit : u8 ) -> io:: Result < ( ) > {
574
+ self . 0 . set_hop_limit_v6 ( limit)
575
+ }
576
+
577
+ /// Gets the value of the `IPV6_UNICAST_HOPS` option on this socket.
578
+ ///
579
+ /// For more information about this option, see [`TcpStream::set_hop_limit_v6`].
580
+ ///
581
+ /// # Examples
582
+ ///
583
+ /// ```no_run
584
+ /// #![feature(ipv6_hop_limit)]
585
+ /// use std::net::TcpStream;
586
+ ///
587
+ /// let stream = TcpStream::connect("[::1]:12345")
588
+ /// .expect("Couldn't connect to the server...");
589
+ /// stream.set_hop_limit_v6(88).expect("set_hop_limit_v6 call failed");
590
+ /// assert_eq!(stream.hop_limit_v6().unwrap(), 88);
591
+ /// ```
592
+ #[ unstable( feature = "ipv6_hop_limit" , issue = "139166" ) ]
593
+ pub fn hop_limit_v6 ( & self ) -> io:: Result < u8 > {
594
+ self . 0 . hop_limit_v6 ( )
595
+ }
596
+
557
597
/// Gets the value of the `SO_ERROR` option on this socket.
558
598
///
559
599
/// This will retrieve the stored error in the underlying socket, clearing
@@ -948,6 +988,44 @@ impl TcpListener {
948
988
self . 0 . ttl ( )
949
989
}
950
990
991
+ /// Sets the value for the `IPV6_UNICAST_HOPS` option on this socket.
992
+ ///
993
+ /// This value sets the unicast hop limit field that is used in every packet
994
+ /// sent from this socket.
995
+ ///
996
+ /// # Examples
997
+ ///
998
+ /// ```no_run
999
+ /// #![feature(ipv6_hop_limit)]
1000
+ /// use std::net::TcpListener;
1001
+ ///
1002
+ /// let listener = TcpListener::bind("[::1]:12345").unwrap();
1003
+ /// listener.set_hop_limit_v6(88).expect("set_hop_limit_v6 call failed");
1004
+ /// ```
1005
+ #[ unstable( feature = "ipv6_hop_limit" , issue = "139166" ) ]
1006
+ pub fn set_hop_limit_v6 ( & self , limit : u8 ) -> io:: Result < ( ) > {
1007
+ self . 0 . set_hop_limit_v6 ( limit)
1008
+ }
1009
+
1010
+ /// Gets the value of the `IPV6_UNICAST_HOPS` option on this socket.
1011
+ ///
1012
+ /// For more information about this option, see [`TcpListener::set_hop_limit_v6`].
1013
+ ///
1014
+ /// # Examples
1015
+ ///
1016
+ /// ```no_run
1017
+ /// #![feature(ipv6_hop_limit)]
1018
+ /// use std::net::TcpListener;
1019
+ ///
1020
+ /// let listener = TcpListener::bind("[::1]:12345").unwrap();
1021
+ /// listener.set_hop_limit_v6(88).expect("set_hop_limit_v6 call failed");
1022
+ /// assert_eq!(listener.hop_limit_v6().unwrap(), 88);
1023
+ /// ```
1024
+ #[ unstable( feature = "ipv6_hop_limit" , issue = "139166" ) ]
1025
+ pub fn hop_limit_v6 ( & self ) -> io:: Result < u8 > {
1026
+ self . 0 . hop_limit_v6 ( )
1027
+ }
1028
+
951
1029
#[ stable( feature = "net2_mutators" , since = "1.9.0" ) ]
952
1030
#[ deprecated( since = "1.16.0" , note = "this option can only be set before the socket is bound" ) ]
953
1031
#[ allow( missing_docs) ]
0 commit comments