Available on crate feature
net
only.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§
- addr
- Types for implementers of socket address types or code that is generic over address types.
- eth
ETH_P_*
constants.- ipproto
IPPROTO_*
constants.- netdevice
- Low-level Linux network device access
- netlink
NETLINK_*
constants.- sockopt
getsockopt
andsetsockopt
functions.- sysproto
SYSPROTO_*
constants.- xdp
AF_XDP
related types and constants.
Macros§
- cmsg_
space - Macro for defining the amount of space to allocate in a buffer for use with
RecvAncillaryBuffer::new
andSendAncillaryBuffer::new
.
Structs§
- Address
Family AF_*
constants for use withsocket
,socket_with
, andsocketpair
.- Ancillary
Drain - An iterator that drains messages from a
RecvAncillaryBuffer
. - Ancillary
Iter - An iterator over data in an ancillary buffer.
- Ipv4
Addr - An IPv4 address.
- Ipv6
Addr - An IPv6 address.
- MMsgHdr
- An ABI-compatible wrapper for
mmsghdr
, for sending multiple messages with sendmmsg. - Protocol
IPPROTO_*
and other constants for use withsocket
,socket_with
, andsocketpair
when a nondefault value is desired.- Recv
Ancillary Buffer - Buffer for receiving ancillary messages with
recvmsg
. - Recv
Flags MSG_*
flags for use withrecv
,recvfrom
, and related functions.- RecvMsg
- The result of a successful
recvmsg
call. - Return
Flags MSG_*
flags returned fromrecvmsg
, in theflags
field ofRecvMsg
- Send
Ancillary Buffer - Buffer for sending ancillary messages with
sendmsg
andsendmsg_addr
. - Send
Flags MSG_*
flags for use withsend
,sendto
, and related functions.- Socket
Addr Any - A type that can hold any kind of socket address, as a safe abstraction for
sockaddr_storage
. - Socket
Addr Unix struct sockaddr_un
- Socket
Addr V4 - An IPv4 socket address.
- Socket
Addr V6 - An IPv6 socket address.
- Socket
Flags SOCK_*
constants for use withsocket_with
,accept_with
andacceptfrom_with
.- Socket
Type SOCK_*
constants for use withsocket
.- UCred
- UNIX credentials of socket peer, for use with
get_socket_peercred
SendAncillaryMessage::ScmCredentials
andRecvAncillaryMessage::ScmCredentials
.
Enums§
- IpAddr
- An IP address, either IPv4 or IPv6.
- Recv
Ancillary Message - Ancillary message for
recvmsg
. - Send
Ancillary Message - Ancillary message for
sendmsg
andsendmsg_addr
. - Shutdown
SHUT_*
constants for use withshutdown
.- Socket
Addr - An internet socket address, either IPv4 or IPv6.
Functions§
- accept
accept(fd, NULL, NULL)
—Accepts an incoming connection.- accept_
with accept4(fd, NULL, NULL, flags)
—Accepts an incoming connection, with flags.- acceptfrom
accept(fd, &addr, &len)
—Accepts an incoming connection and returns the peer address.- acceptfrom_
with accept4(fd, &addr, &len, flags)
—Accepts an incoming connection and returns the peer address, with flags.- bind
bind(sockfd, addr)
—Binds a socket to an IP address.- connect
connect(sockfd, addr)
—Initiates a connection to an IP address.- connect_
unspec connect(sockfd, {.sa_family = AF_UNSPEC}, sizeof(struct sockaddr))
— Dissolve the socket’s association.- getpeername
getpeername(fd, addr, len)
—Returns the address a socket is connected to.- getsockname
getsockname(fd, addr, len)
—Returns the address a socket is bound to.- listen
listen(fd, backlog)
—Enables listening for incoming connections.- recv
recv(fd, buf, flags)
—Reads data from a socket.- recvfrom
recvfrom(fd, buf, flags, addr, len)
—Reads data from a socket and returns the sender address.- recvmsg
recvmsg(msghdr)
—Receives a message from a socket.- send
send(fd, buf, flags)
—Writes data to a socket.- sendmmsg
sendmmsg(msghdr)
—Sends multiple messages on a socket.- sendmsg
sendmsg(msghdr)
—Sends a message on a socket.- sendmsg_
addr sendmsg(msghdr)
—Sends a message on a socket to a specific address.- sendto
sendto(fd, buf, flags, addr)
—Writes data to a socket to a specific IP address.- shutdown
shutdown(fd, how)
—Closes the read and/or write sides of a stream.- socket
socket(domain, type_, protocol)
—Creates a socket.- socket_
with socket_with(domain, type_ | flags, protocol)
—Creates a socket, with flags.- socketpair
socketpair(domain, type_ | accept_flags, protocol)
—Create a pair of sockets that are connected to each other.
Type Aliases§
- RawAddress
Family - A type for holding raw integer address families.
- RawProtocol
- A type for holding raw integer protocols.
- RawSocket
Type - A type for holding raw integer socket types.