Function nix::sys::socket::setsockopt [−][src]
pub fn setsockopt<O: SetSockOpt>(fd: RawFd, opt: O, val: &O::Val) -> Result<()>
Expand description
Sets the value for the requested socket option
Examples
use nix::sys::socket::setsockopt;
use nix::sys::socket::sockopt::KeepAlive;
use std::net::TcpListener;
use std::os::unix::io::AsRawFd;
let listener = TcpListener::bind("0.0.0.0:0").unwrap();
let fd = listener.as_raw_fd();
let res = setsockopt(fd, KeepAlive, &true);
assert!(res.is_ok());