Skip to content

Commit 1ccc9a5

Browse files
committed
Add tcp prefix to TCP multiple methods
* keepalive_time * keepalive_interval * keepalive_retries * nodelay * set_nodelay
1 parent 19359a6 commit 1ccc9a5

File tree

4 files changed

+30
-27
lines changed

4 files changed

+30
-27
lines changed

src/socket.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2119,8 +2119,8 @@ impl Socket {
21192119
target_os = "vita"
21202120
))
21212121
))]
2122-
pub fn keepalive_time(&self) -> io::Result<Duration> {
2123-
sys::keepalive_time(self.as_raw())
2122+
pub fn tcp_keepalive_time(&self) -> io::Result<Duration> {
2123+
sys::tcp_keepalive_time(self.as_raw())
21242124
}
21252125

21262126
/// Get the value of the `TCP_KEEPINTVL` option on this socket.
@@ -2146,7 +2146,7 @@ impl Socket {
21462146
target_os = "cygwin",
21472147
)
21482148
))]
2149-
pub fn keepalive_interval(&self) -> io::Result<Duration> {
2149+
pub fn tcp_keepalive_interval(&self) -> io::Result<Duration> {
21502150
unsafe {
21512151
getsockopt::<c_int>(self.as_raw(), sys::IPPROTO_TCP, sys::TCP_KEEPINTVL)
21522152
.map(|secs| Duration::from_secs(secs as u64))
@@ -2177,7 +2177,7 @@ impl Socket {
21772177
target_os = "windows",
21782178
)
21792179
))]
2180-
pub fn keepalive_retries(&self) -> io::Result<u32> {
2180+
pub fn tcp_keepalive_retries(&self) -> io::Result<u32> {
21812181
unsafe {
21822182
getsockopt::<c_int>(self.as_raw(), sys::IPPROTO_TCP, sys::TCP_KEEPCNT)
21832183
.map(|retries| retries as u32)
@@ -2229,10 +2229,10 @@ impl Socket {
22292229

22302230
/// Get the value of the `TCP_NODELAY` option on this socket.
22312231
///
2232-
/// For more information about this option, see [`set_nodelay`].
2232+
/// For more information about this option, see [`set_tcp_nodelay`].
22332233
///
2234-
/// [`set_nodelay`]: Socket::set_nodelay
2235-
pub fn nodelay(&self) -> io::Result<bool> {
2234+
/// [`set_tcp_nodelay`]: Socket::set_tcp_nodelay
2235+
pub fn tcp_nodelay(&self) -> io::Result<bool> {
22362236
unsafe {
22372237
getsockopt::<Bool>(self.as_raw(), sys::IPPROTO_TCP, sys::TCP_NODELAY)
22382238
.map(|nodelay| nodelay != 0)
@@ -2246,7 +2246,7 @@ impl Socket {
22462246
/// small amount of data. When not set, data is buffered until there is a
22472247
/// sufficient amount to send out, thereby avoiding the frequent sending of
22482248
/// small packets.
2249-
pub fn set_nodelay(&self, nodelay: bool) -> io::Result<()> {
2249+
pub fn set_tcp_nodelay(&self, nodelay: bool) -> io::Result<()> {
22502250
unsafe {
22512251
setsockopt(
22522252
self.as_raw(),

src/sockref.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ use crate::Socket;
4949
///
5050
/// // Create a `SockRef`erence to the stream.
5151
/// let socket_ref = SockRef::from(&stream);
52-
/// // Use `Socket::set_nodelay` on the stream.
53-
/// socket_ref.set_nodelay(true)?;
52+
/// // Use `Socket::set_tcp_nodelay` on the stream.
53+
/// socket_ref.set_tcp_nodelay(true)?;
5454
/// drop(socket_ref);
5555
///
5656
/// assert_eq!(stream.nodelay()?, true);

src/sys/unix.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1565,9 +1565,9 @@ impl crate::Socket {
15651565

15661566
/// Gets the value of the `TCP_MAXSEG` option on this socket.
15671567
///
1568-
/// For more information about this option, see [`set_mss`].
1568+
/// For more information about this option, see [`set_tcp_mss`].
15691569
///
1570-
/// [`set_mss`]: crate::Socket::set_mss
1570+
/// [`set_tcp_mss`]: crate::Socket::set_tcp_mss
15711571
#[cfg(all(feature = "all", not(target_os = "redox")))]
15721572
pub fn tcp_mss(&self) -> io::Result<u32> {
15731573
unsafe {
@@ -1690,9 +1690,9 @@ impl crate::Socket {
16901690

16911691
/// Get the value of the `TCP_CORK` option on this socket.
16921692
///
1693-
/// For more information about this option, see [`set_cork`].
1693+
/// For more information about this option, see [`set_tcp_cork`].
16941694
///
1695-
/// [`set_cork`]: crate::Socket::set_cork
1695+
/// [`set_tcp_cork`]: crate::Socket::set_tcp_cork
16961696
#[cfg(all(
16971697
feature = "all",
16981698
any(target_os = "android", target_os = "fuchsia", target_os = "linux")
@@ -1727,9 +1727,9 @@ impl crate::Socket {
17271727

17281728
/// Get the value of the `TCP_QUICKACK` option on this socket.
17291729
///
1730-
/// For more information about this option, see [`set_quickack`].
1730+
/// For more information about this option, see [`set_tcp_quickack`].
17311731
///
1732-
/// [`set_quickack`]: crate::Socket::set_quickack
1732+
/// [`set_tcp_quickack`]: crate::Socket::set_tcp_quickack
17331733
#[cfg(all(
17341734
feature = "all",
17351735
any(
@@ -1774,9 +1774,9 @@ impl crate::Socket {
17741774

17751775
/// Get the value of the `TCP_THIN_LINEAR_TIMEOUTS` option on this socket.
17761776
///
1777-
/// For more information about this option, see [`set_thin_linear_timeouts`].
1777+
/// For more information about this option, see [`set_tcp_thin_linear_timeouts`].
17781778
///
1779-
/// [`set_thin_linear_timeouts`]: crate::Socket::set_thin_linear_timeouts
1779+
/// [`set_tcp_thin_linear_timeouts`]: crate::Socket::set_tcp_thin_linear_timeouts
17801780
#[cfg(all(
17811781
feature = "all",
17821782
any(target_os = "android", target_os = "fuchsia", target_os = "linux")

tests/socket.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,10 @@ fn tcp_keepalive() {
912912
feature = "all",
913913
not(any(windows, target_os = "haiku", target_os = "openbsd"))
914914
))]
915-
assert_eq!(socket.keepalive_time().unwrap(), Duration::from_secs(200));
915+
assert_eq!(
916+
socket.tcp_keepalive_time().unwrap(),
917+
Duration::from_secs(200)
918+
);
916919

917920
#[cfg(all(
918921
feature = "all",
@@ -932,7 +935,7 @@ fn tcp_keepalive() {
932935
)
933936
))]
934937
assert_eq!(
935-
socket.keepalive_interval().unwrap(),
938+
socket.tcp_keepalive_interval().unwrap(),
936939
Duration::from_secs(30)
937940
);
938941

@@ -954,7 +957,7 @@ fn tcp_keepalive() {
954957
target_os = "windows",
955958
)
956959
))]
957-
assert_eq!(socket.keepalive_retries().unwrap(), 10);
960+
assert_eq!(socket.tcp_keepalive_retries().unwrap(), 10);
958961
}
959962

960963
#[cfg(all(feature = "all", any(target_os = "fuchsia", target_os = "linux")))]
@@ -1350,7 +1353,7 @@ const GET_BUF_SIZE: usize = SET_BUF_SIZE;
13501353
#[cfg(target_os = "linux")]
13511354
const GET_BUF_SIZE: usize = 2 * SET_BUF_SIZE;
13521355

1353-
test!(nodelay, set_nodelay(true));
1356+
test!(tcp_nodelay, set_tcp_nodelay(true));
13541357
test!(
13551358
recv_buffer_size,
13561359
set_recv_buffer_size(SET_BUF_SIZE),
@@ -1383,8 +1386,8 @@ test!(reuse_port_lb, set_reuse_port_lb(true));
13831386
))]
13841387
test!(
13851388
#[cfg_attr(target_os = "linux", ignore = "Different value returned")]
1386-
mss,
1387-
set_mss(256)
1389+
tcp_mss,
1390+
set_tcp_mss(256)
13881391
);
13891392
#[cfg(all(feature = "all", target_os = "linux"))]
13901393
test!(
@@ -1402,17 +1405,17 @@ test!(
14021405
feature = "all",
14031406
any(target_os = "android", target_os = "fuchsia", target_os = "linux")
14041407
))]
1405-
test!(cork, set_cork(true));
1408+
test!(tcp_cork, set_tcp_cork(true));
14061409
#[cfg(all(
14071410
feature = "all",
14081411
any(target_os = "android", target_os = "fuchsia", target_os = "linux")
14091412
))]
1410-
test!(quickack, set_quickack(false));
1413+
test!(tcp_quickack, set_tcp_quickack(false));
14111414
#[cfg(all(
14121415
feature = "all",
14131416
any(target_os = "android", target_os = "fuchsia", target_os = "linux")
14141417
))]
1415-
test!(thin_linear_timeouts, set_thin_linear_timeouts(true));
1418+
test!(tcp_thin_linear_timeouts, set_tcp_thin_linear_timeouts(true));
14161419
test!(linger, set_linger(Some(Duration::from_secs(10))));
14171420
test!(
14181421
read_timeout,

0 commit comments

Comments
 (0)