Trait rasi_syscall::Network

source ·
pub trait Network: Sync + Send {
Show 31 methods // Required methods fn udp_join_multicast_v4( &self, handle: &Handle, multiaddr: &Ipv4Addr, interface: &Ipv4Addr ) -> Result<()>; fn udp_join_multicast_v6( &self, handle: &Handle, multiaddr: &Ipv6Addr, interface: u32 ) -> Result<()>; fn udp_leave_multicast_v4( &self, handle: &Handle, multiaddr: &Ipv4Addr, interface: &Ipv4Addr ) -> Result<()>; fn udp_leave_multicast_v6( &self, handle: &Handle, multiaddr: &Ipv6Addr, interface: u32 ) -> Result<()>; fn udp_set_broadcast(&self, handle: &Handle, on: bool) -> Result<()>; fn udp_broadcast(&self, handle: &Handle) -> Result<bool>; fn udp_ttl(&self, handle: &Handle) -> Result<u32>; fn udp_set_ttl(&self, handle: &Handle, ttl: u32) -> Result<()>; fn udp_local_addr(&self, handle: &Handle) -> Result<SocketAddr>; fn udp_bind( &self, waker: Waker, laddrs: &[SocketAddr] ) -> CancelablePoll<Result<Handle>>; fn udp_send_to( &self, waker: Waker, socket: &Handle, buf: &[u8], target: SocketAddr ) -> CancelablePoll<Result<usize>>; fn udp_recv_from( &self, waker: Waker, socket: &Handle, buf: &mut [u8] ) -> CancelablePoll<Result<(usize, SocketAddr)>>; fn tcp_listener_bind( &self, waker: Waker, laddrs: &[SocketAddr] ) -> CancelablePoll<Result<Handle>>; fn tcp_listener_local_addr(&self, handle: &Handle) -> Result<SocketAddr>; fn tcp_listener_ttl(&self, handle: &Handle) -> Result<u32>; fn tcp_listener_set_ttl(&self, handle: &Handle, ttl: u32) -> Result<()>; fn tcp_listener_accept( &self, waker: Waker, handle: &Handle ) -> CancelablePoll<Result<(Handle, SocketAddr)>>; fn tcp_stream_connect( &self, waker: Waker, raddrs: &[SocketAddr] ) -> CancelablePoll<Result<Handle>>; fn tcp_stream_write( &self, waker: Waker, socket: &Handle, buf: &[u8] ) -> CancelablePoll<Result<usize>>; fn tcp_stream_read( &self, waker: Waker, socket: &Handle, buf: &mut [u8] ) -> CancelablePoll<Result<usize>>; fn tcp_stream_local_addr(&self, handle: &Handle) -> Result<SocketAddr>; fn tcp_stream_remote_addr(&self, handle: &Handle) -> Result<SocketAddr>; fn tcp_stream_nodelay(&self, handle: &Handle) -> Result<bool>; fn tcp_stream_set_nodelay( &self, handle: &Handle, nodelay: bool ) -> Result<()>; fn tcp_stream_ttl(&self, handle: &Handle) -> Result<u32>; fn tcp_stream_set_ttl(&self, handle: &Handle, ttl: u32) -> Result<()>; fn tcp_stream_shutdown(&self, handle: &Handle, how: Shutdown) -> Result<()>; fn unix_listener_bind( &self, waker: Waker, path: &Path ) -> CancelablePoll<Result<Handle>>; fn unix_listener_accept( &self, waker: Waker, handle: &Handle ) -> CancelablePoll<Result<(Handle, SocketAddr)>>; fn unix_listener_local_addr(&self, handle: &Handle) -> Result<SocketAddr>; fn unix_stream_connect( &self, waker: Waker, path: &Path ) -> CancelablePoll<Result<Handle>>;
}
Available on crate feature net only.
Expand description

Network-related system call interface

Required Methods§

source

fn udp_join_multicast_v4( &self, handle: &Handle, multiaddr: &Ipv4Addr, interface: &Ipv4Addr ) -> Result<()>

Executes an operation of the IP_ADD_MEMBERSHIP type.

This function specifies a new multicast group for this socket to join. The address must be a valid multicast address, and interface is the address of the local interface with which the system should join the multicast group. If it’s equal to INADDR_ANY then an appropriate interface is chosen by the system.

source

fn udp_join_multicast_v6( &self, handle: &Handle, multiaddr: &Ipv6Addr, interface: u32 ) -> Result<()>

Executes an operation of the IPV6_ADD_MEMBERSHIP type.

This function specifies a new multicast group for this socket to join. The address must be a valid multicast address, and interface is the index of the interface to join/leave (or 0 to indicate any interface).

source

fn udp_leave_multicast_v4( &self, handle: &Handle, multiaddr: &Ipv4Addr, interface: &Ipv4Addr ) -> Result<()>

Executes an operation of the IP_DROP_MEMBERSHIP type.

For more information about this option, see join_multicast_v4.

source

fn udp_leave_multicast_v6( &self, handle: &Handle, multiaddr: &Ipv6Addr, interface: u32 ) -> Result<()>

Executes an operation of the IPV6_DROP_MEMBERSHIP type.

For more information about this option, see join_multicast_v6.

source

fn udp_set_broadcast(&self, handle: &Handle, on: bool) -> Result<()>

Sets the value of the SO_BROADCAST option for this socket. When enabled, this socket is allowed to send packets to a broadcast address.

source

fn udp_broadcast(&self, handle: &Handle) -> Result<bool>

Gets the value of the SO_BROADCAST option for this socket. For more information about this option, see udp_set_broadcast.

source

fn udp_ttl(&self, handle: &Handle) -> Result<u32>

Gets the value of the IP_TTL option for this socket. For more information about this option, see tcp_listener_set_ttl.

source

fn udp_set_ttl(&self, handle: &Handle, ttl: u32) -> Result<()>

Sets the value for the IP_TTL option on this socket. This value sets the time-to-live field that is used in every packet sent from this socket.

source

fn udp_local_addr(&self, handle: &Handle) -> Result<SocketAddr>

Returns the local socket address bound to this udp socket.

source

fn udp_bind( &self, waker: Waker, laddrs: &[SocketAddr] ) -> CancelablePoll<Result<Handle>>

Create udp socket and bind it to laddrs.

Binding with a port number of 0 will request that the OS assigns a port to this socket. The port allocated can be queried via the udp_local_addr method.

Returns CancelablePoll::Pending(CancelHandle), indicating that the current operation could not be completed immediately and needs to be retried later.

source

fn udp_send_to( &self, waker: Waker, socket: &Handle, buf: &[u8], target: SocketAddr ) -> CancelablePoll<Result<usize>>

Sends data on the socket to the given target address.

On success, returns the number of bytes written.

Returns CancelablePoll::Pending(CancelHandle), indicating that the current operation could not be completed immediately and needs to be retried later.

source

fn udp_recv_from( &self, waker: Waker, socket: &Handle, buf: &mut [u8] ) -> CancelablePoll<Result<(usize, SocketAddr)>>

Receives data from the socket.

On success, returns the number of bytes read and the origin.

Returns CancelablePoll::Pending(CancelHandle), indicating that the current operation could not be completed immediately and needs to be retried later.

source

fn tcp_listener_bind( &self, waker: Waker, laddrs: &[SocketAddr] ) -> CancelablePoll<Result<Handle>>

Create new TcpListener which will be bound to the specified laddrs

The returned listener is ready for accepting connections.

Binding with a port number of 0 will request that the OS assigns a port to this listener. The port allocated can be queried via the tcp_listener_local_addr method.

Returns CancelablePoll::Pending(CancelHandle), indicating that the current operation could not be completed immediately and needs to be retried later.

source

fn tcp_listener_local_addr(&self, handle: &Handle) -> Result<SocketAddr>

Returns the local socket address bound to this tcp listener.

source

fn tcp_listener_ttl(&self, handle: &Handle) -> Result<u32>

Gets the value of the IP_TTL option for this socket. For more information about this option, see tcp_listener_set_ttl.

source

fn tcp_listener_set_ttl(&self, handle: &Handle, ttl: u32) -> Result<()>

Sets the value for the IP_TTL option on this socket. This value sets the time-to-live field that is used in every packet sent from this socket.

source

fn tcp_listener_accept( &self, waker: Waker, handle: &Handle ) -> CancelablePoll<Result<(Handle, SocketAddr)>>

Accepts a new incoming connection to this tcp listener.

When a connection is established, the corresponding stream and address will be returned.

Returns CancelablePoll::Pending(CancelHandle), indicating that the current operation could not be completed immediately and needs to be retried later.

source

fn tcp_stream_connect( &self, waker: Waker, raddrs: &[SocketAddr] ) -> CancelablePoll<Result<Handle>>

Create a new TcpStream and connect to raddrs.

The port allocated can be queried via the tcp_stream_local_addr method.

Returns CancelablePoll::Pending(CancelHandle), indicating that the current operation could not be completed immediately and needs to be retried later.

source

fn tcp_stream_write( &self, waker: Waker, socket: &Handle, buf: &[u8] ) -> CancelablePoll<Result<usize>>

Sends data on the socket to the remote address

On success, returns the number of bytes written.

source

fn tcp_stream_read( &self, waker: Waker, socket: &Handle, buf: &mut [u8] ) -> CancelablePoll<Result<usize>>

Receives data from the socket.

On success, returns the number of bytes read.

source

fn tcp_stream_local_addr(&self, handle: &Handle) -> Result<SocketAddr>

Returns the local socket address bound to this tcp stream.

source

fn tcp_stream_remote_addr(&self, handle: &Handle) -> Result<SocketAddr>

Returns the remote socket address this tcp stream connected.

source

fn tcp_stream_nodelay(&self, handle: &Handle) -> Result<bool>

Gets the value of the TCP_NODELAY option on this socket. For more information about this option, see tcp_stream_set_nodelay.

source

fn tcp_stream_set_nodelay(&self, handle: &Handle, nodelay: bool) -> Result<()>

Sets the value of the TCP_NODELAY option on this socket.

If set, this option disables the Nagle algorithm. This means that segments are always sent as soon as possible, even if there is only a small amount of data. When not set, data is buffered until there is a sufficient amount to send out, thereby avoiding the frequent sending of small packets.

source

fn tcp_stream_ttl(&self, handle: &Handle) -> Result<u32>

Gets the value of the IP_TTL option for this socket. For more information about this option, see tcp_listener_set_ttl.

source

fn tcp_stream_set_ttl(&self, handle: &Handle, ttl: u32) -> Result<()>

Sets the value for the IP_TTL option on this socket. This value sets the time-to-live field that is used in every packet sent from this socket.

source

fn tcp_stream_shutdown(&self, handle: &Handle, how: Shutdown) -> Result<()>

Shuts down the read, write, or both halves of this connection. This function will cause all pending and future I/O on the specified portions to return immediately with an appropriate value (see the documentation of Shutdown).

source

fn unix_listener_bind( &self, waker: Waker, path: &Path ) -> CancelablePoll<Result<Handle>>

Creates a new UnixListener bound to the specified socket path.

source

fn unix_listener_accept( &self, waker: Waker, handle: &Handle ) -> CancelablePoll<Result<(Handle, SocketAddr)>>

Accepts a new incoming connection to this listener. The call is responsible for ensuring that the listening socket is in non-blocking mode.

source

fn unix_listener_local_addr(&self, handle: &Handle) -> Result<SocketAddr>

Returns the local socket address of this listener.

source

fn unix_stream_connect( &self, waker: Waker, path: &Path ) -> CancelablePoll<Result<Handle>>

Connects to the unix socket named by address.

Implementors§