docs

std::os::unix::net

本页内容

API 参考只有英文版,由标准库源代码中的英文文档注释生成。

Unix domain sockets. Like the TCP ones: non-blocking underneath, set_*_timeout bounds the blocking calls, *_async suspend the task. A listener's accept gives the peer's bound path (none: unnamed). A stream connect waits only for a full backlog; connect_async waits on a blocking thread.

Structs

UnixStreamSource

pub struct UnixStream

A Unix stream socket. It has one owner (let b = a moves it); close it with try s.close() or using.

  • pub fn connect<P: AsPath>(path: P) throws (IoError) -> UnixStream§

    Source

    Connect to the socket at path.

  • pub async fn connect_async<P: AsPath>(path: P) throws (IoError) -> UnixStream§

    Source

    connect that suspends the task until the connection is made.

  • pub fn pair() throws (IoError) -> (UnixStream, UnixStream)§

    Source

    Two connected ends (socketpair).

  • pub fn send_with_fd<B: AsBytes>(self, buf: B, fd: RawFd) throws (IoError) -> usize§

    Source

    buf with fd fd alongside (SCM_RIGHTS): the bytes sent.

  • pub async fn send_with_fd_async<B: AsBytes>(ref self, buf: B, fd: RawFd) throws (IoError) -> usize§

    Source

    send_with_fd that suspends the task while the socket is full.

  • pub fn recv_with_fd(self, buf: SliceMut<u8>) throws (IoError) -> (usize, RawFd | none)§

    Source

    One read into buf and the fd passed with it, if any (the caller owns it; it is close-on-exec).

  • pub async fn recv_with_fd_async(ref self, buf: SliceMut<u8>) throws (IoError) -> (usize, RawFd | none)§

    Source

    recv_with_fd that suspends the task until data arrives.

  • pub fn peer_addr(self) throws (IoError) -> Path | none§

    Source

    The peer's path; none when unnamed.

  • pub fn local_addr(self) throws (IoError) -> Path | none§

    Source

    The path this socket is bound to; none when unnamed.

  • pub fn shutdown(self, how: Shutdown) throws (IoError)§

    Source

    Shut down reading, writing or both.

  • pub async fn shutdown_async(ref self, how: Shutdown) throws (IoError)§

    Source

    As shutdown, which never waits.

  • pub const fn set_read_timeout(self, dur: Duration | none)§

    Source

    Limit blocking reads to dur, then TimedOut; none waits forever.

  • pub const fn set_write_timeout(self, dur: Duration | none)§

    Source

    Limit blocking writes to dur, then TimedOut; none waits forever.

  • pub const fn set_nonblocking(self, nb: bool)§

    Source

    Make blocking calls throw WouldBlock instead of waiting.

  • pub fn try_clone(self) throws (IoError) -> UnixStream§

    Source

    A second handle to the same socket.

  • pub fn split(self) -> (ReadHalf<UnixStream>, WriteHalf<UnixStream>)§

    Source

    Split into a read half and a write half, as TcpStream::split.

  • pub fn close(self) throws (IoError)§

    Source

    Close now, throwing the OS's error.

Trait implementations 11

UnixListenerSource

pub struct UnixListener

A listening Unix stream socket bound to a path.

  • pub fn bind<P: AsPath>(path: P) throws (IoError) -> UnixListener§

    Source

    Bind path (it must not exist yet) and listen (backlog 128).

  • pub fn accept(self) throws (IoError) -> (UnixStream, Path | none)§

    Source

    The next connection and the path its peer is bound to (none: unnamed, the usual case), blocking until one arrives.

  • pub async fn accept_async(ref self) throws (IoError) -> (UnixStream, Path | none)§

    Source

    accept that suspends the task until a connection arrives.

  • pub fn local_addr(self) throws (IoError) -> Path | none§

    Source

    The path this socket is bound to; none when unnamed.

  • pub const fn set_nonblocking(self, nb: bool)§

    Source

    Make accept throw WouldBlock instead of waiting.

  • pub fn try_clone(self) throws (IoError) -> UnixListener§

    Source

    A second handle to the same socket.

  • pub fn close(self) throws (IoError)§

    Source

    Close now, throwing the OS's error.

Trait implementations 7

UnixDatagramSource

pub struct UnixDatagram

A Unix datagram socket.

  • pub fn bind<P: AsPath>(path: P) throws (IoError) -> UnixDatagram§

    Source

    A datagram socket bound to path.

  • pub fn connect<P: AsPath>(path: P) throws (IoError) -> UnixDatagram§

    Source

    A datagram socket connected to path (unbound itself).

  • pub async fn connect_async<P: AsPath>(path: P) throws (IoError) -> UnixDatagram§

    Source

    As connect, which never waits for a datagram socket.

  • pub fn pair() throws (IoError) -> (UnixDatagram, UnixDatagram)§

    Source

    Two connected datagram ends (socketpair).

  • pub fn send<B: AsBytes>(self, buf: B) throws (IoError) -> usize§

    Source

    Send the datagram buf to the connected peer; bytes sent.

  • pub async fn send_async<B: AsBytes>(ref self, buf: B) throws (IoError) -> usize§

    Source

    send that suspends the task while the socket is full.

  • pub fn recv(self, buf: SliceMut<u8>) throws (IoError) -> usize§

    Source

    The next datagram into buf[0..n] (truncated to buf.len()).

  • pub async fn recv_async(ref self, buf: SliceMut<u8>) throws (IoError) -> usize§

    Source

    recv that suspends the task until a datagram arrives.

  • pub fn send_with_fd<B: AsBytes>(self, buf: B, fd: RawFd) throws (IoError) -> usize§

    Source

    send with fd passed alongside (SCM_RIGHTS).

  • pub async fn send_with_fd_async<B: AsBytes>(ref self, buf: B, fd: RawFd) throws (IoError) -> usize§

    Source

    send_with_fd that suspends the task while the socket is full.

  • pub fn recv_with_fd(self, buf: SliceMut<u8>) throws (IoError) -> (usize, RawFd | none)§

    Source

    recv with the descriptor passed alongside, if any.

  • pub async fn recv_with_fd_async(ref self, buf: SliceMut<u8>) throws (IoError) -> (usize, RawFd | none)§

    Source

    recv_with_fd that suspends the task until a datagram arrives.

  • pub fn local_addr(self) throws (IoError) -> Path | none§

    Source

    The path this socket is bound to; none when unnamed.

  • pub const fn set_read_timeout(self, dur: Duration | none)§

    Source

    Limit blocking reads to dur, then TimedOut; none waits forever.

  • pub const fn set_write_timeout(self, dur: Duration | none)§

    Source

    Limit blocking writes to dur, then TimedOut; none waits forever.

  • pub const fn set_nonblocking(self, nb: bool)§

    Source

    Make blocking calls throw WouldBlock instead of waiting.

  • pub fn close(self) throws (IoError)§

    Source

    Close now, throwing the OS's error.

Trait implementations 7

Implementations

impl ReadHalf

  • pub fn unsplit(self, w: WriteHalf<UnixStream>) -> UnixStream§

    Source

    The stream again, from this half and the WriteHalf that split gave with it. Panics on a write half of another stream.