[−][src]Struct mio::tcp::TcpListener
Methods
impl TcpListener
[src]
pub fn bind(addr: &SocketAddr) -> Result<TcpListener>
[src]
Convenience method to bind a new TCP listener to the specified address to receive new connections.
This function will take the following steps:
- Create a new TCP socket.
- Set the
SO_REUSEADDR
option on the socket. - Bind the socket to the specified address.
- Call
listen
on the socket to prepare it to receive new connections.
If fine-grained control over the binding and listening process for a
socket is desired then the net2::TcpBuilder
methods can be used in
combination with the TcpListener::from_listener
method to transfer
ownership into mio.
pub fn from_listener(
listener: TcpListener,
addr: &SocketAddr
) -> Result<TcpListener>
[src]
listener: TcpListener,
addr: &SocketAddr
) -> Result<TcpListener>
Creates a new TcpListener
from an instance of a
std::net::TcpListener
type.
This function will set the listener
provided into nonblocking mode on
Unix, and otherwise the stream will just be wrapped up in an mio stream
ready to accept new connections and become associated with an event
loop.
The address provided must be the address that the listener is bound to.
pub fn accept(&self) -> Result<Option<(TcpStream, SocketAddr)>>
[src]
Accepts a new TcpStream
.
Returns a Ok(None)
when the socket WOULDBLOCK
, this means the stream
will be ready at a later point. If an accepted stream is returned, the
address of the peer is returned along with it
pub fn local_addr(&self) -> Result<SocketAddr>
[src]
pub fn try_clone(&self) -> Result<TcpListener>
[src]
pub fn take_socket_error(&self) -> Result<()>
[src]
Trait Implementations
impl Evented for TcpListener
[src]
fn register(
&self,
selector: &mut Selector,
token: Token,
interest: EventSet,
opts: PollOpt
) -> Result<()>
[src]
&self,
selector: &mut Selector,
token: Token,
interest: EventSet,
opts: PollOpt
) -> Result<()>
fn reregister(
&self,
selector: &mut Selector,
token: Token,
interest: EventSet,
opts: PollOpt
) -> Result<()>
[src]
&self,
selector: &mut Selector,
token: Token,
interest: EventSet,
opts: PollOpt
) -> Result<()>
fn deregister(&self, selector: &mut Selector) -> Result<()>
[src]
impl TryAccept for TcpListener
[src]
impl Debug for TcpListener
[src]
impl AsRawFd for TcpListener
[src]
impl FromRawFd for TcpListener
[src]
unsafe fn from_raw_fd(fd: RawFd) -> TcpListener
[src]
Auto Trait Implementations
impl Send for TcpListener
impl !Sync for TcpListener
impl Unpin for TcpListener
impl UnwindSafe for TcpListener
impl !RefUnwindSafe for TcpListener
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
ⓘImportant traits for &'_ mut Wfn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,