Struct TcpListener
pub struct TcpListener { /* private fields */ }
sync
only.Expand description
A TCP socket server, listening for connections.
This corresponds to std::net::TcpListener
.
This TcpListener
has no bind
method. To bind it to a socket address,
first obtain a Pool
permitting the address, and then call
Pool::bind_tcp_listener
.
Implementations§
§impl TcpListener
impl TcpListener
pub fn from_std(std: TcpListener) -> TcpListener
pub fn from_std(std: TcpListener) -> TcpListener
Constructs a new instance of Self
from the given
std::net::TcpListener
.
This grants access the resources the std::net::TcpListener
instance
already has access to.
pub fn local_addr(&self) -> Result<SocketAddr, Error>
pub fn local_addr(&self) -> Result<SocketAddr, Error>
Returns the local socket address of this listener.
This corresponds to std::net::TcpListener::local_addr
.
pub fn try_clone(&self) -> Result<TcpListener, Error>
pub fn try_clone(&self) -> Result<TcpListener, Error>
Creates a new independently owned handle to the underlying socket.
This corresponds to std::net::TcpListener::try_clone
.
pub fn accept(&self) -> Result<(TcpStream, SocketAddr), Error>
pub fn accept(&self) -> Result<(TcpStream, SocketAddr), Error>
Accept a new incoming connection from this listener.
This corresponds to std::net::TcpListener::accept
.
pub fn incoming(&self) -> Incoming<'_>
pub fn incoming(&self) -> Incoming<'_>
Returns an iterator over the connections being received on this listener.
This corresponds to std::net::TcpListener::incoming
.
pub fn set_ttl(&self, ttl: u32) -> Result<(), Error>
pub fn set_ttl(&self, ttl: u32) -> Result<(), Error>
Sets the value for the IP_TTL
option on this socket.
This corresponds to std::net::TcpListener::set_ttl
.
pub fn ttl(&self) -> Result<u32, Error>
pub fn ttl(&self) -> Result<u32, Error>
Gets the value of the IP_TTL
option for this socket.
This corresponds to std::net::TcpListener::ttl
.
pub fn take_error(&self) -> Result<Option<Error>, Error>
pub fn take_error(&self) -> Result<Option<Error>, Error>
Gets the value of the SO_ERROR
option on this socket.
This corresponds to std::net::TcpListener::take_error
.
pub fn set_nonblocking(&self, nonblocking: bool) -> Result<(), Error>
pub fn set_nonblocking(&self, nonblocking: bool) -> Result<(), Error>
Moves this TCP stream into or out of nonblocking mode.
This corresponds to std::net::TcpListener::set_nonblocking
.
Trait Implementations§
§impl AsFd for TcpListener
impl AsFd for TcpListener
§fn as_fd(&self) -> BorrowedFd<'_>
fn as_fd(&self) -> BorrowedFd<'_>
§impl Debug for TcpListener
impl Debug for TcpListener
§impl From<OwnedFd> for TcpListener
impl From<OwnedFd> for TcpListener
§fn from(fd: OwnedFd) -> TcpListener
fn from(fd: OwnedFd) -> TcpListener
Source§impl From<TcpListener> for Socket
impl From<TcpListener> for Socket
Source§fn from(listener: TcpListener) -> Self
fn from(listener: TcpListener) -> Self
§impl FromRawFd for TcpListener
impl FromRawFd for TcpListener
§unsafe fn from_raw_fd(fd: i32) -> TcpListener
unsafe fn from_raw_fd(fd: i32) -> TcpListener
Self
from the given raw file
descriptor. Read more§impl IntoRawFd for TcpListener
impl IntoRawFd for TcpListener
§fn into_raw_fd(self) -> i32
fn into_raw_fd(self) -> i32
impl SocketlikeViewType for TcpListener
Auto Trait Implementations§
impl Freeze for TcpListener
impl RefUnwindSafe for TcpListener
impl Send for TcpListener
impl Sync for TcpListener
impl Unpin for TcpListener
impl UnwindSafe for TcpListener
Blanket Implementations§
§impl<T> AsFilelike for Twhere
T: AsFd,
impl<T> AsFilelike for Twhere
T: AsFd,
§fn as_filelike(&self) -> BorrowedFd<'_>
fn as_filelike(&self) -> BorrowedFd<'_>
§fn as_filelike_view<Target>(&self) -> FilelikeView<'_, Target>where
Target: FilelikeViewType,
fn as_filelike_view<Target>(&self) -> FilelikeView<'_, Target>where
Target: FilelikeViewType,
&Target
. Read more§impl<T> AsGrip for Twhere
T: AsFd,
impl<T> AsGrip for Twhere
T: AsFd,
§fn as_grip(&self) -> BorrowedFd<'_>
fn as_grip(&self) -> BorrowedFd<'_>
§impl<T> AsRawFilelike for Twhere
T: AsRawFd,
impl<T> AsRawFilelike for Twhere
T: AsRawFd,
§fn as_raw_filelike(&self) -> i32
fn as_raw_filelike(&self) -> i32
§impl<T> AsRawGrip for Twhere
T: AsRawFd,
impl<T> AsRawGrip for Twhere
T: AsRawFd,
§fn as_raw_grip(&self) -> i32
fn as_raw_grip(&self) -> i32
§impl<T> AsRawSocketlike for Twhere
T: AsRawFd,
impl<T> AsRawSocketlike for Twhere
T: AsRawFd,
§fn as_raw_socketlike(&self) -> i32
fn as_raw_socketlike(&self) -> i32
§impl<T> AsSocketlike for Twhere
T: AsFd,
impl<T> AsSocketlike for Twhere
T: AsFd,
§fn as_socketlike(&self) -> BorrowedFd<'_>
fn as_socketlike(&self) -> BorrowedFd<'_>
§fn as_socketlike_view<Target>(&self) -> SocketlikeView<'_, Target>where
Target: SocketlikeViewType,
fn as_socketlike_view<Target>(&self) -> SocketlikeView<'_, Target>where
Target: SocketlikeViewType,
&Target
. Read moreSource§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> FileIoExt for Twhere
T: AsFilelike + IoExt,
impl<T> FileIoExt for Twhere
T: AsFilelike + IoExt,
§fn advise(&self, offset: u64, len: u64, advice: Advice) -> Result<(), Error>
fn advise(&self, offset: u64, len: u64, advice: Advice) -> Result<(), Error>
§fn allocate(&self, offset: u64, len: u64) -> Result<(), Error>
fn allocate(&self, offset: u64, len: u64) -> Result<(), Error>
§fn read_at(&self, buf: &mut [u8], offset: u64) -> Result<usize, Error>
fn read_at(&self, buf: &mut [u8], offset: u64) -> Result<usize, Error>
§fn read_exact_at(&self, buf: &mut [u8], offset: u64) -> Result<(), Error>
fn read_exact_at(&self, buf: &mut [u8], offset: u64) -> Result<(), Error>
§fn read_vectored_at(
&self,
bufs: &mut [IoSliceMut<'_>],
offset: u64,
) -> Result<usize, Error>
fn read_vectored_at( &self, bufs: &mut [IoSliceMut<'_>], offset: u64, ) -> Result<usize, Error>
read_vectored
what read_at
is to read
.§fn is_read_vectored_at(&self) -> bool
fn is_read_vectored_at(&self) -> bool
FileIoExt
implementation has an efficient
read_vectored_at
implementation.§fn read_to_end_at(&self, buf: &mut Vec<u8>, offset: u64) -> Result<usize, Error>
fn read_to_end_at(&self, buf: &mut Vec<u8>, offset: u64) -> Result<usize, Error>
offset
, until EOF in this source, placing
them into buf
.§fn read_to_string_at(
&self,
buf: &mut String,
offset: u64,
) -> Result<usize, Error>
fn read_to_string_at( &self, buf: &mut String, offset: u64, ) -> Result<usize, Error>
offset
, until EOF in this source,
appending them to buf
.§fn write_at(&self, buf: &[u8], offset: u64) -> Result<usize, Error>
fn write_at(&self, buf: &[u8], offset: u64) -> Result<usize, Error>
§fn write_all_at(&self, buf: &[u8], offset: u64) -> Result<(), Error>
fn write_all_at(&self, buf: &[u8], offset: u64) -> Result<(), Error>
§fn write_vectored_at(
&self,
bufs: &[IoSlice<'_>],
offset: u64,
) -> Result<usize, Error>
fn write_vectored_at( &self, bufs: &[IoSlice<'_>], offset: u64, ) -> Result<usize, Error>
write_vectored
what write_at
is to write
.§fn is_write_vectored_at(&self) -> bool
fn is_write_vectored_at(&self) -> bool
FileIoExt
implementation has an efficient
write_vectored_at
implementation.§fn append(&self, buf: &[u8]) -> Result<usize, Error>
fn append(&self, buf: &[u8]) -> Result<usize, Error>
§fn append_vectored(&self, bufs: &[IoSlice<'_>]) -> Result<usize, Error>
fn append_vectored(&self, bufs: &[IoSlice<'_>]) -> Result<usize, Error>
append
what write_vectored
is to write
.§fn is_append_vectored(&self) -> bool
fn is_append_vectored(&self) -> bool
FileIoExt
implementation has an efficient
append_vectored
implementation.§fn seek(&self, pos: SeekFrom) -> Result<u64, Error>
fn seek(&self, pos: SeekFrom) -> Result<u64, Error>
§fn stream_position(&self) -> Result<u64, Error>
fn stream_position(&self) -> Result<u64, Error>
§fn read_exact_vectored_at(
&self,
bufs: &mut [IoSliceMut<'_>],
offset: u64,
) -> Result<(), Error>
fn read_exact_vectored_at( &self, bufs: &mut [IoSliceMut<'_>], offset: u64, ) -> Result<(), Error>
read_exact_vectored
what read_exact_at
is to read_exact
.§fn write_all_vectored_at(
&self,
bufs: &mut [IoSlice<'_>],
offset: u64,
) -> Result<(), Error>
fn write_all_vectored_at( &self, bufs: &mut [IoSlice<'_>], offset: u64, ) -> Result<(), Error>
write_all_vectored
what write_all_at
is to write_all
.§impl<T> FromFd for T
impl<T> FromFd for T
§impl<T> FromFilelike for T
impl<T> FromFilelike for T
§fn from_filelike(owned: OwnedFd) -> T
fn from_filelike(owned: OwnedFd) -> T
Self
from the given filelike object. Read more§fn from_into_filelike<Owned>(owned: Owned) -> Twhere
Owned: IntoFilelike,
fn from_into_filelike<Owned>(owned: Owned) -> Twhere
Owned: IntoFilelike,
Self
from the given filelike object
converted from into_owned
. Read more§impl<T> FromGrip for T
impl<T> FromGrip for T
§impl<T> FromRawFilelike for Twhere
T: FromRawFd,
impl<T> FromRawFilelike for Twhere
T: FromRawFd,
§unsafe fn from_raw_filelike(raw: i32) -> T
unsafe fn from_raw_filelike(raw: i32) -> T
Self
from the raw value. Read more§impl<T> FromRawGrip for Twhere
T: FromRawFd,
impl<T> FromRawGrip for Twhere
T: FromRawFd,
§unsafe fn from_raw_grip(raw_grip: i32) -> T
unsafe fn from_raw_grip(raw_grip: i32) -> T
§impl<T> FromRawSocketlike for Twhere
T: FromRawFd,
impl<T> FromRawSocketlike for Twhere
T: FromRawFd,
§unsafe fn from_raw_socketlike(raw: i32) -> T
unsafe fn from_raw_socketlike(raw: i32) -> T
Self
from the raw value. Read more§impl<T> FromSocketlike for T
impl<T> FromSocketlike for T
§fn from_socketlike(owned: OwnedFd) -> T
fn from_socketlike(owned: OwnedFd) -> T
Self
from the given socketlike object.§fn from_into_socketlike<Owned>(owned: Owned) -> Twhere
Owned: IntoSocketlike,
fn from_into_socketlike<Owned>(owned: Owned) -> Twhere
Owned: IntoSocketlike,
Self
from the given socketlike object
converted from into_owned
.§impl<T> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
self
file descriptor.§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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§impl<T> IntoFd for T
impl<T> IntoFd for T
§impl<T> IntoFilelike for T
impl<T> IntoFilelike for T
§fn into_filelike(self) -> OwnedFd
fn into_filelike(self) -> OwnedFd
§impl<T> IntoGrip for T
impl<T> IntoGrip for T
§impl<T> IntoRawFilelike for Twhere
T: IntoRawFd,
impl<T> IntoRawFilelike for Twhere
T: IntoRawFd,
§fn into_raw_filelike(self) -> i32
fn into_raw_filelike(self) -> i32
§impl<T> IntoRawGrip for Twhere
T: IntoRawFd,
impl<T> IntoRawGrip for Twhere
T: IntoRawFd,
§fn into_raw_grip(self) -> i32
fn into_raw_grip(self) -> i32
self
and convert into an RawGrip
.§impl<T> IntoRawSocketlike for Twhere
T: IntoRawFd,
impl<T> IntoRawSocketlike for Twhere
T: IntoRawFd,
§fn into_raw_socketlike(self) -> i32
fn into_raw_socketlike(self) -> i32
§impl<T> IntoSocketlike for T
impl<T> IntoSocketlike for T
§fn into_socketlike(self) -> OwnedFd
fn into_socketlike(self) -> OwnedFd
§impl<T> IoExt for Twhere
T: AsFilelike + AsSocketlike,
impl<T> IoExt for Twhere
T: AsFilelike + AsSocketlike,
§fn read(&self, buf: &mut [u8]) -> Result<usize, Error>
fn read(&self, buf: &mut [u8]) -> Result<usize, Error>
§fn read_exact(&self, buf: &mut [u8]) -> Result<(), Error>
fn read_exact(&self, buf: &mut [u8]) -> Result<(), Error>
buf
. Read more§fn read_vectored(&self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
fn read_vectored(&self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
read
, except that it reads into a slice of buffers. Read more§fn read_to_end(&self, buf: &mut Vec<u8>) -> Result<usize, Error>
fn read_to_end(&self, buf: &mut Vec<u8>) -> Result<usize, Error>
buf
. Read more§fn read_to_string(&self, buf: &mut String) -> Result<usize, Error>
fn read_to_string(&self, buf: &mut String) -> Result<usize, Error>
buf
. Read more§fn peek(&self, buf: &mut [u8]) -> Result<usize, Error>
fn peek(&self, buf: &mut [u8]) -> Result<usize, Error>
§fn write(&self, buf: &[u8]) -> Result<usize, Error>
fn write(&self, buf: &[u8]) -> Result<usize, Error>
§fn write_all(&self, buf: &[u8]) -> Result<(), Error>
fn write_all(&self, buf: &[u8]) -> Result<(), Error>
§fn write_vectored(&self, bufs: &[IoSlice<'_>]) -> Result<usize, Error>
fn write_vectored(&self, bufs: &[IoSlice<'_>]) -> Result<usize, Error>
write
, except that it writes from a slice of buffers. Read more§fn flush(&self) -> Result<(), Error>
fn flush(&self) -> Result<(), Error>
§fn write_fmt(&self, fmt: Arguments<'_>) -> Result<(), Error>
fn write_fmt(&self, fmt: Arguments<'_>) -> Result<(), Error>
§fn read_exact_vectored(&self, bufs: &mut [IoSliceMut<'_>]) -> Result<(), Error>
fn read_exact_vectored(&self, bufs: &mut [IoSliceMut<'_>]) -> Result<(), Error>
read_vectored
what read_exact
is to read
.