Skip to content

Commit 4339598

Browse files
committed
Add tcp prefix to TCP multiple methods
* keepalive_time * keepalive_interval * keepalive_retries * nodelay * set_nodelay
1 parent 88fb1f5 commit 4339598

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

src/socket.rs

Lines changed: 6 additions & 6 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)
@@ -2232,7 +2232,7 @@ impl Socket {
22322232
/// For more information about this option, see [`set_nodelay`].
22332233
///
22342234
/// [`set_nodelay`]: Socket::set_nodelay
2235-
pub fn nodelay(&self) -> io::Result<bool> {
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);

tests/socket.rs

Lines changed: 9 additions & 6 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!(

0 commit comments

Comments
 (0)