Skip to content

Commit

Permalink
Keepalive interval is constant 2h on vita
Browse files Browse the repository at this point in the history
  • Loading branch information
nikarh committed Sep 12, 2023
1 parent 4147f50 commit 0db00f4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ use std::mem;
use std::mem::MaybeUninit;
use std::net::SocketAddr;
use std::ops::{Deref, DerefMut};
#[cfg(not(any(target_os = "vita")))]
use std::time::Duration;

/// Macro to implement `fmt::Debug` for a type, printing the constant names
Expand Down Expand Up @@ -426,6 +427,7 @@ impl<'a> DerefMut for MaybeUninitSlice<'a> {
#[derive(Debug, Clone)]
pub struct TcpKeepalive {
#[cfg_attr(target_os = "openbsd", allow(dead_code))]
#[cfg(not(any(target_os = "vita")))]
time: Option<Duration>,
#[cfg(not(any(
target_os = "openbsd",
Expand All @@ -452,6 +454,7 @@ impl TcpKeepalive {
/// Returns a new, empty set of TCP keepalive parameters.
pub const fn new() -> TcpKeepalive {
TcpKeepalive {
#[cfg(not(any(target_os = "vita")))]
time: None,
#[cfg(not(any(
target_os = "openbsd",
Expand Down Expand Up @@ -486,6 +489,8 @@ impl TcpKeepalive {
///
/// Some platforms specify this value in seconds, so sub-second
/// specifications may be omitted.
///
#[cfg(not(any(target_os = "vita")))]
pub const fn with_time(self, time: Duration) -> Self {
Self {
time: Some(time),
Expand Down
4 changes: 3 additions & 1 deletion tests/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,9 @@ fn udp_pair_connected() -> (Socket, Socket) {
#[test]
fn tcp_keepalive() {
let socket = Socket::new(Domain::IPV4, Type::STREAM, None).unwrap();
let params = TcpKeepalive::new().with_time(Duration::from_secs(200));
let params = TcpKeepalive::new();
#[cfg(not(any(target_os = "vita")))]
let params = params.with_time(Duration::from_secs(200));

#[cfg(all(
feature = "all",
Expand Down

0 comments on commit 0db00f4

Please sign in to comment.