Fix std::sys::unix::set_linger for Cygwin
Signed-off-by: Ookiineko <chiisaineko@protonmail.com>
This commit is contained in:
parent
c9ccec93fa
commit
e3e98c84d3
1 changed files with 11 additions and 0 deletions
|
|
@ -424,6 +424,7 @@ impl Socket {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "cygwin"))]
|
||||
pub fn set_linger(&self, linger: Option<Duration>) -> io::Result<()> {
|
||||
let linger = libc::linger {
|
||||
l_onoff: linger.is_some() as libc::c_int,
|
||||
|
|
@ -433,6 +434,16 @@ impl Socket {
|
|||
setsockopt(self, libc::SOL_SOCKET, SO_LINGER, linger)
|
||||
}
|
||||
|
||||
#[cfg(target_os = "cygwin")]
|
||||
pub fn set_linger(&self, linger: Option<Duration>) -> io::Result<()> {
|
||||
let linger = libc::linger {
|
||||
l_onoff: linger.is_some() as libc::c_ushort,
|
||||
l_linger: linger.unwrap_or_default().as_secs() as libc::c_ushort,
|
||||
};
|
||||
|
||||
setsockopt(self, libc::SOL_SOCKET, SO_LINGER, linger)
|
||||
}
|
||||
|
||||
pub fn linger(&self) -> io::Result<Option<Duration>> {
|
||||
let val: libc::linger = getsockopt(self, libc::SOL_SOCKET, SO_LINGER)?;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue