macro_rules! setsockopt_impl {
($name:ident, $level:expr, $flag:path, $ty:ty, $setter:ty) => { ... };
}
Available on crate feature
socket
only.Expand description
Helper for implementing SetSockOpt
for a given socket option. See
::sys::socket::SetSockOpt
.
This macro aims to help implementing SetSockOpt
for different socket options that accept
different kinds of data to be used with setsockopt
.
Instead of using this macro directly consider using sockopt_impl!
,
especially if the option you are implementing represents a simple type.
ยงArguments
$name:ident
: name of the type you want to implementSetSockOpt
for.$level:expr
: socket layer, or aprotocol level
: could be raw sockets (libc::SOL_SOCKET
), ip protocol (libc::IPPROTO_IP), tcp protocol (libc::IPPROTO_TCP
), and more. Please refer to your system manual for more options. Will be passed as the second argument (level
) to thesetsockopt
call.$flag:path
: a flag name to set. Some examples:libc::SO_REUSEADDR
,libc::TCP_NODELAY
,libc::IP_ADD_MEMBERSHIP
and others. Will be passed as the third argument (option_name
) to thesetsockopt
call.- Type of the value that you are going to set.
- Type that implements the
Set
trait for the type from the previous item (likeSetBool
forbool
,SetUsize
forusize
, etc.).