Skip to main content

Socket

Struct Socket 

Source
pub struct Socket(FileDesc);

Tuple Fields§

§0: FileDesc

Implementations§

Source§

impl Socket

Source

pub fn new(family: c_int, ty: c_int) -> Result<Socket>

Source

pub fn new_pair(fam: c_int, ty: c_int) -> Result<(Socket, Socket)>

Available on neither VxWorks nor WASI.
Source

pub fn connect(&self, addr: &SocketAddr) -> Result<()>

Source

pub fn connect_timeout( &self, addr: &SocketAddr, timeout: Duration, ) -> Result<()>

Source

pub fn accept( &self, storage: *mut sockaddr, len: *mut socklen_t, ) -> Result<Socket>

Source

pub fn duplicate(&self) -> Result<Socket>

Source

pub fn send_with_flags(&self, buf: &[u8], flags: c_int) -> Result<usize>

Available on non-WASI only.
Source

fn recv_with_flags(&self, buf: BorrowedCursor<'_>, flags: c_int) -> Result<()>

Source

pub fn read(&self, buf: &mut [u8]) -> Result<usize>

Source

pub fn peek(&self, buf: &mut [u8]) -> Result<usize>

Source

pub fn read_buf(&self, buf: BorrowedCursor<'_>) -> Result<()>

Source

pub fn read_vectored(&self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize>

Source

pub fn is_read_vectored(&self) -> bool

Source

fn recv_from_with_flags( &self, buf: &mut [u8], flags: c_int, ) -> Result<(usize, SocketAddr)>

Source

pub fn recv_from(&self, buf: &mut [u8]) -> Result<(usize, SocketAddr)>

Source

pub fn recv_msg(&self, msg: &mut msghdr) -> Result<usize>

Available on Android or Linux or Cygwin only.
Source

pub fn peek_from(&self, buf: &mut [u8]) -> Result<(usize, SocketAddr)>

Source

pub fn write(&self, buf: &[u8]) -> Result<usize>

Available on non-WASI only.
Source

pub fn write_vectored(&self, bufs: &[IoSlice<'_>]) -> Result<usize>

Source

pub fn is_write_vectored(&self) -> bool

Source

pub fn send_msg(&self, msg: &mut msghdr) -> Result<usize>

Available on Android or Linux or Cygwin only.
Source

pub fn set_timeout(&self, dur: Option<Duration>, kind: c_int) -> Result<()>

Source

pub fn timeout(&self, kind: c_int) -> Result<Option<Duration>>

Source

pub fn shutdown(&self, how: Shutdown) -> Result<()>

Source

pub fn set_linger(&self, linger: Option<Duration>) -> Result<()>

Available on non-Cygwin only.
Source

pub fn linger(&self) -> Result<Option<Duration>>

Source

pub fn set_nodelay(&self, nodelay: bool) -> Result<()>

Source

pub fn nodelay(&self) -> Result<bool>

Source

pub fn set_quickack(&self, quickack: bool) -> Result<()>

Available on Android or Linux or Cygwin only.
Source

pub fn quickack(&self) -> Result<bool>

Available on Android or Linux or Cygwin only.
Source

pub fn set_deferaccept(&self, accept: Duration) -> Result<()>

Available on Linux only.
Source

pub fn deferaccept(&self) -> Result<Duration>

Available on Linux only.
Source

pub fn set_passcred(&self, passcred: bool) -> Result<()>

Available on Android or Linux or Cygwin only.
Source

pub fn passcred(&self) -> Result<bool>

Available on Android or Linux or Cygwin only.
Source

pub fn set_nonblocking(&self, nonblocking: bool) -> Result<()>

Available on neither Solaris nor illumos nor Play Station Vita.
Source

pub fn set_mark(&self, mark: u32) -> Result<()>

Available on Linux or FreeBSD or OpenBSD only.
Source

pub fn take_error(&self) -> Result<Option<Error>>

Source

pub fn as_raw(&self) -> RawFd

Trait Implementations§

Source§

impl AsFd for Socket

Source§

fn as_fd(&self) -> BorrowedFd<'_>

Available on Unix or Hermit or Trusty or WASI or Motor OS only.
Borrows the file descriptor. Read more
Source§

impl AsInner<FileDesc> for Socket

Source§

impl AsInner<Socket> for TcpStream

Source§

fn as_inner(&self) -> &Socket

Source§

impl AsInner<Socket> for UnixDatagram

Available on non-Hermit and (Unix) and not ((WebAssembly and non-WASI, or Fortanix and SGX)) only.
Source§

fn as_inner(&self) -> &Socket

Source§

impl AsInner<Socket> for UnixStream

Available on non-Hermit and (Unix) and not ((WebAssembly and non-WASI, or Fortanix and SGX)) only.
Source§

fn as_inner(&self) -> &Socket

Source§

impl AsRawFd for Socket

Source§

fn as_raw_fd(&self) -> RawFd

Available on Unix or Hermit or Trusty or WASI or Motor OS only.
Extracts the raw file descriptor. Read more
Source§

impl FromInner<FileDesc> for Socket

Source§

fn from_inner(file_desc: FileDesc) -> Self

Source§

impl FromInner<Socket> for TcpListener

Source§

impl FromInner<Socket> for TcpStream

Source§

impl FromInner<Socket> for UdpSocket

Source§

impl FromRawFd for Socket

Source§

unsafe fn from_raw_fd(raw_fd: RawFd) -> Self

Available on Unix or Hermit or Trusty or WASI or Motor OS only.
Constructs a new instance of Self from the given raw file descriptor. Read more
Source§

impl IntoInner<FileDesc> for Socket

Source§

impl IntoRawFd for Socket

Source§

fn into_raw_fd(self) -> RawFd

Available on Unix or Hermit or Trusty or WASI or Motor OS only.
Consumes this object, returning the raw underlying file descriptor. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> SizedTypeProperties for T

Source§

#[doc(hidden)]
const SIZE: usize = _

🔬This is a nightly-only experimental API. (sized_type_properties)
Source§

#[doc(hidden)]
const ALIGN: usize = _

🔬This is a nightly-only experimental API. (sized_type_properties)
Source§

#[doc(hidden)]
const ALIGNMENT: Alignment = _

🔬This is a nightly-only experimental API. (ptr_alignment_type #102070)
Source§

#[doc(hidden)]
const IS_ZST: bool = _

🔬This is a nightly-only experimental API. (sized_type_properties)
true if this type requires no storage. false if its size is greater than zero. Read more
Source§

#[doc(hidden)]
const LAYOUT: Layout = _

🔬This is a nightly-only experimental API. (sized_type_properties)
Source§

#[doc(hidden)]
const MAX_SLICE_LEN: usize = _

🔬This is a nightly-only experimental API. (sized_type_properties)
The largest safe length for a [Self]. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.