[][src]Struct spirit_tokio::net::Listen

#[non_exhaustive]pub struct Listen {
    pub port: u16,
    pub host: IpAddr,
    pub reuse_addr: Option<bool>,
    pub reuse_port: Option<bool>,
    pub only_v6: Option<bool>,
    pub backlog: u32,
    pub ttl: Option<u32>,
}

A description of listening interface and port.

This can be used as part of configuration to describe a socket.

Note that the Default implementation is there to provide something on creation of Spirit, but isn't very useful. It'll listen on a OS-assigned port on all the interfaces.

This is used as the base of the TcpListen and UdpListen configuration fragments.

Configuration options

Fields (Non-exhaustive)

Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
port: u16

The port to bind to.

host: IpAddr

The interface to bind to.

Defaults to :: (IPv6 any).

reuse_addr: Option<bool>

The SO_REUSEADDR socket option.

Usually, the OS reserves the host-port pair for a short time after it has been released, so leftovers of old connections don't confuse the new application. The SO_REUSEADDR option asks the OS not to do this reservation.

If not set, it is left on the OS default (which is likely off = doing the reservation).

reuse_port: Option<bool>

The SO_REUSEPORT socket option.

Setting this to true allows multiple applications to simultaneously bind to the same port.

If not set, it is left on the OS default (which is likely off).

This option is not available on Windows and has no effect there.

only_v6: Option<bool>

The IP_V6ONLY option.

This has no effect on IPv4 sockets.

On IPv6 sockets, this restricts the socket to sending and receiving only IPv6 packets. This allows another socket to bind the same port on IPv4. If it is set to false, the socket can communicate with both IPv6 and IPv4 endpoints under some circumstances.

Due to platform differences, the generally accepted best practice is to bind IPv4 and IPv6 as two separate sockets, the IPv6 one with setting IP_V6ONLY explicitly to true.

If not set, it is left on the OS default (which differs from OS to OS).

backlog: u32

The accepting backlog.

Has no effect for UDP sockets.

This specifies how many connections can wait in the kernel before being accepted. If more than this limit are queued, the kernel starts refusing them with connection reset packets.

The default is 128.

ttl: Option<u32>

The TTL field of IP packets sent from this socket.

If not set, it defaults to the OS value.

Implementations

impl Listen[src]

pub fn create_tcp(&self) -> Result<StdTcpListener, AnyError>[src]

Creates a TCP socket described by the loaded configuration.

This is the synchronous socket from standard library. See TcpListener::from_std.

pub fn create_udp(&self) -> Result<StdUdpSocket, AnyError>[src]

Creates a UDP socket described by the loaded configuration.

This is the synchronous socket from standard library. See UdpSocket::from_std.

Trait Implementations

impl Clone for Listen[src]

impl Debug for Listen[src]

impl Default for Listen[src]

impl<'de> Deserialize<'de> for Listen[src]

impl Eq for Listen[src]

impl Hash for Listen[src]

impl Ord for Listen[src]

impl PartialEq<Listen> for Listen[src]

impl PartialOrd<Listen> for Listen[src]

impl Serialize for Listen[src]

impl StructDoc for Listen[src]

impl StructuralEq for Listen[src]

impl StructuralPartialEq for Listen[src]

Auto Trait Implementations

impl RefUnwindSafe for Listen

impl Send for Listen

impl Sync for Listen

impl Unpin for Listen

impl UnwindSafe for Listen

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> IntoResult<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.