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