Module net

Source
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§

eth
ETH_P_* constants.
ipproto
IPPROTO_* constants.
netdevice
Low-level Linux network device access
netlink
NETLINK_* constants.
sockopt
getsockopt and setsockopt 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 and SendAncillaryBuffer::new.

Structs§

AddressFamily
AF_* constants for use with socket, socket_with, and socketpair.
AncillaryDrain
An iterator that drains messages from a RecvAncillaryBuffer.
AncillaryIter
An iterator over data in an ancillary buffer.
Ipv4Addr
An IPv4 address.
Ipv6Addr
An IPv6 address.
Protocol
IPPROTO_* and other constants for use with socket, socket_with, and socketpair when a nondefault value is desired.
RecvAncillaryBuffer
Buffer for receiving ancillary messages with recvmsg.
RecvFlags
MSG_* flags for use with recv, recvfrom, and related functions.
RecvMsgReturn
The result of a successful recvmsg call.
SendAncillaryBuffer
Buffer for sending ancillary messages with sendmsg, sendmsg_v4, sendmsg_v6, sendmsg_unix, and sendmsg_any.
SendFlags
MSG_* flags for use with send, sendto, and related functions.
SocketAddrUnix
struct sockaddr_un
SocketAddrV4
An IPv4 socket address.
SocketAddrV6
An IPv6 socket address.
SocketFlags
SOCK_* constants for use with socket_with, accept_with and acceptfrom_with.
SocketType
SOCK_* constants for use with socket.
UCred
UNIX credentials of socket peer, for use with get_socket_peercred SendAncillaryMessage::ScmCredentials and RecvAncillaryMessage::ScmCredentials.

Enums§

IpAddr
An IP address, either IPv4 or IPv6.
RecvAncillaryMessage
Ancillary message for recvmsg.
SendAncillaryMessage
Ancillary message for sendmsg, sendmsg_v4, sendmsg_v6, sendmsg_unix, and sendmsg_any.
Shutdown
SHUT_* constants for use with shutdown.
SocketAddr
An internet socket address, either IPv4 or IPv6.
SocketAddrAny
struct sockaddr_storage as a Rust enum.

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.
bind_any
bind(sockfd, addr)—Binds a socket to an address.
bind_unix
bind(sockfd, addr, sizeof(struct sockaddr_un))—Binds a socket to a Unix-domain address.
bind_v4
bind(sockfd, addr, sizeof(struct sockaddr_in))—Binds a socket to an IPv4 address.
bind_v6
bind(sockfd, addr, sizeof(struct sockaddr_in6))—Binds a socket to an IPv6 address.
bind_xdp
bind(sockfd, addr, sizeof(struct sockaddr_un))—Binds a socket to a XDP address.
connect
connect(sockfd, addr)—Initiates a connection to an IP address.
connect_any
connect(sockfd, addr)—Initiates a connection.
connect_unix
connect(sockfd, addr, sizeof(struct sockaddr_un))—Initiates a connection to a Unix-domain address.
connect_unspec
connect(sockfd, {.sa_family = AF_UNSPEC}, sizeof(struct sockaddr))— Dissolve the socket’s association.
connect_v4
connect(sockfd, addr, sizeof(struct sockaddr_in))—Initiates a connection to an IPv4 address.
connect_v6
connect(sockfd, addr, sizeof(struct sockaddr_in6))—Initiates a connection to an IPv6 address.
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.
recv_uninit
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.
recvfrom_uninit
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.
sendmsg
sendmsg(msghdr)—Sends a message on a socket.
sendmsg_any
sendmsg(msghdr)—Sends a message on a socket to a specific address.
sendmsg_unix
sendmsg(msghdr)—Sends a message on a socket to a specific Unix-domain address.
sendmsg_v4
sendmsg(msghdr)—Sends a message on a socket to a specific IPv4 address.
sendmsg_v6
sendmsg(msghdr)—Sends a message on a socket to a specific IPv6 address.
sendmsg_xdp
sendmsg(msghdr)—Sends a message on a socket to a specific XDP address.
sendto
sendto(fd, buf, flags, addr)—Writes data to a socket to a specific IP address.
sendto_any
sendto(fd, buf, flags, addr)—Writes data to a socket to a specific address.
sendto_unix
sendto(fd, buf, flags, addr, sizeof(struct sockaddr_un))—Writes data to a socket to a specific Unix-domain socket address.
sendto_v4
sendto(fd, buf, flags, addr, sizeof(struct sockaddr_in))—Writes data to a socket to a specific IPv4 address.
sendto_v6
sendto(fd, buf, flags, addr, sizeof(struct sockaddr_in6))—Writes data to a socket to a specific IPv6 address.
sendto_xdp
sendto(fd, buf, flags, addr, sizeof(struct sockaddr_xdp))—Writes data to a socket to a specific XDP 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§

RawAddressFamily
A type for holding raw integer address families.
RawProtocol
A type for holding raw integer protocols.
RawSocketType
A type for holding raw integer socket types.
SocketAddrStorage
struct sockaddr_storage as a raw struct.