Expand description
Network-related operations.
On Windows, one must call wsa_startup
in the process before calling any
of these APIs. wsa_cleanup
may be used in the process if these APIs are
no longer needed.
Re-exports§
pub use crate::net::AddressFamily;
pub use crate::net::Protocol;
pub use crate::net::Shutdown;
pub use crate::net::SocketFlags;
pub use crate::net::SocketType;
Modules§
ETH_P_*
constants.IPPROTO_*
constants.- Low-level Linux network device access
NETLINK_*
constants.getsockopt
andsetsockopt
functions.SYSPROTO_*
constants.AF_XDP
related types and constants.
Macros§
- Macro for defining the amount of space to allocate in a buffer for use with
RecvAncillaryBuffer::new
andSendAncillaryBuffer::new
.
Structs§
- An iterator that drains messages from a
RecvAncillaryBuffer
. - An iterator over data in an ancillary buffer.
- An IPv4 address.
- An IPv6 address.
IPPROTO_*
and other constants for use withsocket
,socket_with
, andsocketpair
when a nondefault value is desired.- Buffer for receiving ancillary messages with
recvmsg
. - The result of a successful
recvmsg
call. - Buffer for sending ancillary messages with
sendmsg
,sendmsg_v4
,sendmsg_v6
,sendmsg_unix
, andsendmsg_any
. struct sockaddr_un
- An IPv4 socket address.
- An IPv6 socket address.
SOCK_*
constants for use withsocket
.- UNIX credentials of socket peer, for use with
get_socket_peercred
SendAncillaryMessage::ScmCredentials
andRecvAncillaryMessage::ScmCredentials
.
Enums§
- An IP address, either IPv4 or IPv6.
- Ancillary message for
recvmsg
. SHUT_*
constants for use withshutdown
.- An internet socket address, either IPv4 or IPv6.
struct sockaddr_storage
as a Rust enum.
Functions§
accept(fd, NULL, NULL)
—Accepts an incoming connection.accept4(fd, NULL, NULL, flags)
—Accepts an incoming connection, with flags.accept(fd, &addr, &len)
—Accepts an incoming connection and returns the peer address.accept4(fd, &addr, &len, flags)
—Accepts an incoming connection and returns the peer address, with flags.bind(sockfd, addr)
—Binds a socket to an IP address.bind(sockfd, addr)
—Binds a socket to an address.bind(sockfd, addr, sizeof(struct sockaddr_un))
—Binds a socket to a Unix-domain address.bind(sockfd, addr, sizeof(struct sockaddr_in))
—Binds a socket to an IPv4 address.bind(sockfd, addr, sizeof(struct sockaddr_in6))
—Binds a socket to an IPv6 address.bind(sockfd, addr, sizeof(struct sockaddr_un))
—Binds a socket to a XDP address.connect(sockfd, addr)
—Initiates a connection to an IP address.connect(sockfd, addr)
—Initiates a connection.connect(sockfd, addr, sizeof(struct sockaddr_un))
—Initiates a connection to a Unix-domain address.connect(sockfd, {.sa_family = AF_UNSPEC}, sizeof(struct sockaddr))
— Dissolve the socket’s association.connect(sockfd, addr, sizeof(struct sockaddr_in))
—Initiates a connection to an IPv4 address.connect(sockfd, addr, sizeof(struct sockaddr_in6))
—Initiates a connection to an IPv6 address.getpeername(fd, addr, len)
—Returns the address a socket is connected to.getsockname(fd, addr, len)
—Returns the address a socket is bound to.listen(fd, backlog)
—Enables listening for incoming connections.recv(fd, buf, flags)
—Reads data from a socket.recv(fd, buf, flags)
—Reads data from a socket.recvfrom(fd, buf, flags, addr, len)
—Reads data from a socket and returns the sender address.recvfrom(fd, buf, flags, addr, len)
—Reads data from a socket and returns the sender address.recvmsg(msghdr)
—Receives a message from a socket.send(fd, buf, flags)
—Writes data to a socket.sendmsg(msghdr)
—Sends a message on a socket.sendmsg(msghdr)
—Sends a message on a socket to a specific address.sendmsg(msghdr)
—Sends a message on a socket to a specific Unix-domain address.sendmsg(msghdr)
—Sends a message on a socket to a specific IPv4 address.sendmsg(msghdr)
—Sends a message on a socket to a specific IPv6 address.sendmsg(msghdr)
—Sends a message on a socket to a specific XDP address.sendto(fd, buf, flags, addr)
—Writes data to a socket to a specific IP address.sendto(fd, buf, flags, addr)
—Writes data to a socket to a specific address.sendto(fd, buf, flags, addr, sizeof(struct sockaddr_un))
—Writes data to a socket to a specific Unix-domain socket address.sendto(fd, buf, flags, addr, sizeof(struct sockaddr_in))
—Writes data to a socket to a specific IPv4 address.sendto(fd, buf, flags, addr, sizeof(struct sockaddr_in6))
—Writes data to a socket to a specific IPv6 address.sendto(fd, buf, flags, addr, sizeof(struct sockaddr_xdp))
—Writes data to a socket to a specific XDP address.shutdown(fd, how)
—Closes the read and/or write sides of a stream.socket(domain, type_, protocol)
—Creates a socket.socket_with(domain, type_ | flags, protocol)
—Creates a socket, with flags.socketpair(domain, type_ | accept_flags, protocol)
—Create a pair of sockets that are connected to each other.
Type Aliases§
- A type for holding raw integer address families.
- A type for holding raw integer protocols.
- A type for holding raw integer socket types.
struct sockaddr_storage
as a raw struct.