Struct tokio_seqpacket::UnixSeqpacketListener
source · pub struct UnixSeqpacketListener { /* private fields */ }
Expand description
Listener for Unix seqpacket sockets.
Implementations§
source§impl UnixSeqpacketListener
impl UnixSeqpacketListener
sourcepub fn bind<P: AsRef<Path>>(address: P) -> Result<Self>
pub fn bind<P: AsRef<Path>>(address: P) -> Result<Self>
Bind a new seqpacket listener to the given address.
The create listener will be ready to accept new connections.
sourcepub fn bind_with_backlog<P: AsRef<Path>>(
address: P,
backlog: c_int
) -> Result<Self>
pub fn bind_with_backlog<P: AsRef<Path>>( address: P, backlog: c_int ) -> Result<Self>
Bind a new seqpacket listener to the given address.
The create listener will be ready to accept new connections.
The backlog
parameter is used to determine the size of connection queue.
See man 3 listen
for more information.
sourcepub unsafe fn from_raw_fd(fd: RawFd) -> Result<Self>
pub unsafe fn from_raw_fd(fd: RawFd) -> Result<Self>
Wrap a raw file descriptor as UnixSeqpacket
.
Registration of the file descriptor with the tokio runtime may fail.
For that reason, this function returns a std::io::Result
.
Safety
This function is unsafe because the socket assumes it is the sole owner of the file descriptor. Usage of this function could accidentally allow violating this contract which can cause memory unsafety in code that relies on it being true.
sourcepub fn into_raw_fd(self) -> RawFd
pub fn into_raw_fd(self) -> RawFd
Deregister the socket from the tokio runtime and return the inner file descriptor.
sourcepub fn local_addr(&self) -> Result<PathBuf>
pub fn local_addr(&self) -> Result<PathBuf>
Get the socket address of the local half of this connection.
sourcepub fn take_error(&self) -> Result<Option<Error>>
pub fn take_error(&self) -> Result<Option<Error>>
Get and clear the value of the SO_ERROR
option.
sourcepub fn poll_accept(
&mut self,
cx: &mut Context<'_>
) -> Poll<Result<UnixSeqpacket>>
pub fn poll_accept( &mut self, cx: &mut Context<'_> ) -> Poll<Result<UnixSeqpacket>>
Check if there is a connection ready to accept.
Note that unlike Self::accept
, only the last task calling this function will be woken up.
For that reason, it is preferable to use the async functions rather than polling functions when possible.
Note that this function does not return a remote address for the accepted connection. This is because connected Unix sockets are anonymous and have no meaningful address.
sourcepub async fn accept(&mut self) -> Result<UnixSeqpacket>
pub async fn accept(&mut self) -> Result<UnixSeqpacket>
Accept a new incoming connection on the listener.
This function is safe to call concurrently from different tasks. Although no order is guaranteed, all calling tasks will try to complete the asynchronous action.
Note that this function does not return a remote address for the accepted connection. This is because connected Unix sockets are anonymous and have no meaningful address.