@@ -259,6 +259,10 @@ impl UdpSocket {
259259 }
260260 }
261261
262+ fn as_socket ( & self ) -> socket2:: SockRef < ' _ > {
263+ socket2:: SockRef :: from ( self )
264+ }
265+
262266 /// Returns the local address that this socket is bound to.
263267 ///
264268 /// # Example
@@ -1510,6 +1514,61 @@ impl UdpSocket {
15101514 self . io . set_ttl ( ttl)
15111515 }
15121516
1517+ /// Gets the value of the `IP_TOS` option for this socket.
1518+ ///
1519+ /// For more information about this option, see [`set_tos`].
1520+ ///
1521+ /// **NOTE:** On Windows, `IP_TOS` is only supported on [Windows 8+ or
1522+ /// Windows Server 2012+.](https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ip-socket-options)
1523+ ///
1524+ /// [`set_tos`]: Self::set_tos
1525+ // https://docs.rs/socket2/0.4.2/src/socket2/socket.rs.html#1178
1526+ #[ cfg( not( any(
1527+ target_os = "fuchsia" ,
1528+ target_os = "redox" ,
1529+ target_os = "solaris" ,
1530+ target_os = "illumos" ,
1531+ ) ) ) ]
1532+ #[ cfg_attr(
1533+ docsrs,
1534+ doc( cfg( not( any(
1535+ target_os = "fuchsia" ,
1536+ target_os = "redox" ,
1537+ target_os = "solaris" ,
1538+ target_os = "illumos" ,
1539+ ) ) ) )
1540+ ) ]
1541+ pub fn tos ( & self ) -> io:: Result < u32 > {
1542+ self . as_socket ( ) . tos ( )
1543+ }
1544+
1545+ /// Sets the value for the `IP_TOS` option on this socket.
1546+ ///
1547+ /// This value sets the time-to-live field that is used in every packet sent
1548+ /// from this socket.
1549+ ///
1550+ /// **NOTE:** On Windows, `IP_TOS` is only supported on [Windows 8+ or
1551+ /// Windows Server 2012+.](https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ip-socket-options)
1552+ // https://docs.rs/socket2/0.4.2/src/socket2/socket.rs.html#1178
1553+ #[ cfg( not( any(
1554+ target_os = "fuchsia" ,
1555+ target_os = "redox" ,
1556+ target_os = "solaris" ,
1557+ target_os = "illumos" ,
1558+ ) ) ) ]
1559+ #[ cfg_attr(
1560+ docsrs,
1561+ doc( cfg( not( any(
1562+ target_os = "fuchsia" ,
1563+ target_os = "redox" ,
1564+ target_os = "solaris" ,
1565+ target_os = "illumos" ,
1566+ ) ) ) )
1567+ ) ]
1568+ pub fn set_tos ( & self , tos : u32 ) -> io:: Result < ( ) > {
1569+ self . as_socket ( ) . set_tos ( tos)
1570+ }
1571+
15131572 /// Executes an operation of the `IP_ADD_MEMBERSHIP` type.
15141573 ///
15151574 /// This function specifies a new multicast group for this socket to join.
0 commit comments