pub struct RawSocket { /* private fields */ }Expand description
A raw IP socket used for ICMP and ICMPv6 traffic.
Implementations§
Source§impl RawSocket
impl RawSocket
Sourcepub fn new(ip_version: IpVersion, ip_protocol: IpProtocol) -> Self
pub fn new(ip_version: IpVersion, ip_protocol: IpProtocol) -> Self
Creates a raw socket for the given IP version and protocol.
Sourcepub fn new_ipv4_ping() -> Self
pub fn new_ipv4_ping() -> Self
Creates an IPv4 ICMP ping socket with Linux SOCK_DGRAM semantics.
Sourcepub fn bind_device(&self, interface_id: InterfaceId) -> NetResult
pub fn bind_device(&self, interface_id: InterfaceId) -> NetResult
Restricts this socket to one interface for route selection.
Trait Implementations§
Source§impl Configurable for RawSocket
impl Configurable for RawSocket
Source§fn get_option_inner(&self, option: &mut GetSocketOption<'_>) -> NetResult<bool>
fn get_option_inner(&self, option: &mut GetSocketOption<'_>) -> NetResult<bool>
Get a socket option, returns
true if the socket supports the option.Source§fn set_option_inner(&self, option: SetSocketOption<'_>) -> NetResult<bool>
fn set_option_inner(&self, option: SetSocketOption<'_>) -> NetResult<bool>
Set a socket option, returns
true if the socket supports the option.Source§fn get_option(&self, opt: GetSocketOption<'_>) -> NetResult
fn get_option(&self, opt: GetSocketOption<'_>) -> NetResult
Get a socket option. Dispatches to
Configurable::get_option_inner.Source§fn set_option(&self, opt: SetSocketOption<'_>) -> NetResult
fn set_option(&self, opt: SetSocketOption<'_>) -> NetResult
Set a socket option. Dispatches to
Configurable::set_option_inner.Source§impl SocketOps for RawSocket
impl SocketOps for RawSocket
Source§fn bind(&self, local_addr: SocketAddrEx) -> NetResult
fn bind(&self, local_addr: SocketAddrEx) -> NetResult
Binds an unbound socket to the given address and port.
Source§fn start_connect(&self, remote_addr: SocketAddrEx) -> NetResult<ConnectStatus>
fn start_connect(&self, remote_addr: SocketAddrEx) -> NetResult<ConnectStatus>
Starts a connection without waiting for asynchronous completion.
Source§fn try_send(
&self,
src: impl Read + IoBuf,
options: &mut SendOptions,
) -> NetResult<usize>
fn try_send( &self, src: impl Read + IoBuf, options: &mut SendOptions, ) -> NetResult<usize>
Attempts to send data without parking the caller.
Source§fn try_recv(
&self,
dst: impl Write + IoBufMut,
options: &mut RecvOptions<'_>,
) -> NetResult<usize>
fn try_recv( &self, dst: impl Write + IoBufMut, options: &mut RecvOptions<'_>, ) -> NetResult<usize>
Attempts to receive data without parking the caller.
Source§fn local_addr(&self) -> NetResult<SocketAddrEx>
fn local_addr(&self) -> NetResult<SocketAddrEx>
Get the local endpoint of the socket.
Source§fn peer_addr(&self) -> NetResult<SocketAddrEx>
fn peer_addr(&self) -> NetResult<SocketAddrEx>
Get the remote endpoint of the socket.
Source§fn connect_status(&self) -> NetResult<ConnectStatus>
fn connect_status(&self) -> NetResult<ConnectStatus>
Checks a previously started asynchronous connection.
Source§fn listen(&self, _backlog: usize) -> NetResult
fn listen(&self, _backlog: usize) -> NetResult
Starts listening on the bound address and port.
Source§fn is_listening(&self) -> bool
fn is_listening(&self) -> bool
Returns whether this socket currently accepts incoming connections.
Source§fn try_accept(&self) -> NetResult<Socket>
fn try_accept(&self) -> NetResult<Socket>
Attempts to accept one connection without parking the caller.
Source§fn recv_available(&self) -> NetResult<usize>
fn recv_available(&self) -> NetResult<usize>
Returns the number of bytes that can be read without blocking.
Source§fn send_wait_policy(
&self,
extra_nonblocking: bool,
) -> NetResult<SocketWaitPolicy>
fn send_wait_policy( &self, extra_nonblocking: bool, ) -> NetResult<SocketWaitPolicy>
Returns the send wait policy without acquiring scheduler ownership.
Source§fn recv_wait_policy(
&self,
extra_nonblocking: bool,
) -> NetResult<SocketWaitPolicy>
fn recv_wait_policy( &self, extra_nonblocking: bool, ) -> NetResult<SocketWaitPolicy>
Returns the receive wait policy without acquiring scheduler ownership.
Auto Trait Implementations§
impl !Freeze for RawSocket
impl !RefUnwindSafe for RawSocket
impl !UnwindSafe for RawSocket
impl Send for RawSocket
impl Sync for RawSocket
impl Unpin for RawSocket
impl UnsafeUnpin for RawSocket
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more