pub fn set_socket_option<T>(
fd: c_int,
level: c_int,
name: c_int,
val: &T,
) -> Result<()>Expand description
setsockopt wrapper
The libc setsockopt function is set to set various options on a socket.
set_socket_option offers a somewhat type-safe wrapper that does not
require messing around with *const c_voids.
A proper std::io::Error will be returned on failure.
Example use:
let fd = ...; // some file descriptor, this will be stdout
set_socket_option(fd, SOL_TCP, TCP_NO_DELAY, 1 as c_int)Note that the val parameter must be specified correctly; if an option
expects an integer, it is advisable to pass in a c_int, not the default
of i32.