Struct UnixSocket
pub struct UnixSocket { /* private fields */ }net only.Expand description
A Unix socket that has not yet been converted to a UnixStream or
UnixListener.
Implementations§
§impl UnixSocket
impl UnixSocket
pub async fn new_stream() -> Result<UnixSocket, Error>
pub async fn new_stream() -> Result<UnixSocket, Error>
Creates a new Unix stream socket.
pub fn local_addr(&self) -> Result<SockAddr, Error>
pub fn local_addr(&self) -> Result<SockAddr, Error>
Returns the local address that this socket is bound to.
pub fn take_error(&self) -> Result<Option<Error>, Error>
pub fn take_error(&self) -> Result<Option<Error>, Error>
Returns the value of the SO_ERROR option.
pub async fn bind(&self, path: impl AsRef<Path>) -> Result<(), Error>
pub async fn bind(&self, path: impl AsRef<Path>) -> Result<(), Error>
Binds the socket to the given address.
pub async fn bind_addr(&self, addr: &SockAddr) -> Result<(), Error>
pub async fn bind_addr(&self, addr: &SockAddr) -> Result<(), Error>
Binds the socket to the given address.
pub async fn listen(self, backlog: i32) -> Result<UnixListener, Error>
pub async fn listen(self, backlog: i32) -> Result<UnixListener, Error>
Converts the socket into a UnixListener.
backlog defines the maximum number of pending connections are queued
by the operating system at any given time. Connections are removed from
the queue with UnixListener::accept. When the queue is full, the
operating-system will start rejecting connections.
pub async fn connect(self, path: impl AsRef<Path>) -> Result<UnixStream, Error>
pub async fn connect(self, path: impl AsRef<Path>) -> Result<UnixStream, Error>
Establishes a Unix connection with a peer at the specified socket address.
See UnixSocket::connect_addr for more details.
pub async fn connect_addr(self, addr: &SockAddr) -> Result<UnixStream, Error>
pub async fn connect_addr(self, addr: &SockAddr) -> Result<UnixStream, Error>
Establishes a Unix connection with a peer at the specified socket address.
The UnixSocket is consumed. Once the connection is established, a
connected UnixStream is returned. If the connection fails, the
encountered error is returned.
On Windows, the socket should be bound to an empty address before connecting.
Trait Implementations§
§impl AsFd for UnixSocket
Available on Unix only.
impl AsFd for UnixSocket
§fn as_fd(&self) -> BorrowedFd<'_>
fn as_fd(&self) -> BorrowedFd<'_>
§impl Debug for UnixSocket
impl Debug for UnixSocket
§impl FromRawFd for UnixSocket
Available on Unix only.
impl FromRawFd for UnixSocket
§unsafe fn from_raw_fd(fd: i32) -> UnixSocket
unsafe fn from_raw_fd(fd: i32) -> UnixSocket
Self from the given raw file
descriptor. Read moreSharedFd.Auto Trait Implementations§
impl Freeze for UnixSocket
impl RefUnwindSafe for UnixSocket
impl Send for UnixSocket
impl Sync for UnixSocket
impl Unpin for UnixSocket
impl UnsafeUnpin for UnixSocket
impl UnwindSafe for UnixSocket
Blanket Implementations§
§impl<T> AsSource for Twhere
T: AsFd,
impl<T> AsSource for Twhere
T: AsFd,
§fn source(&self) -> BorrowedFd<'_>
fn source(&self) -> BorrowedFd<'_>
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more