[−][src]Struct spirit_tokio::net::Listen
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
port
(mandatory)host
(optional, if not present,::
is used)reuse-addr
(optional, boolean, if not present the OS default is used)reuse-port
(optional, boolean, if not present the OS default is used, does something only on unix).only-v6
(optional, boolean, if not present the OS default is used, does nothing for IPv4 sockets).backlog
(optional, number of waiting connections to be accepted in the OS queue, defaults to 128)ttl
(TTL of the listening/UDP socket).
Fields (Non-exhaustive)
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]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl Eq for Listen
[src]
impl Hash for Listen
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl Ord for Listen
[src]
fn cmp(&self, other: &Listen) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl PartialEq<Listen> for Listen
[src]
impl PartialOrd<Listen> for Listen
[src]
fn partial_cmp(&self, other: &Listen) -> Option<Ordering>
[src]
fn lt(&self, other: &Listen) -> bool
[src]
fn le(&self, other: &Listen) -> bool
[src]
fn gt(&self, other: &Listen) -> bool
[src]
fn ge(&self, other: &Listen) -> bool
[src]
impl Serialize for Listen
[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl StructDoc for Listen
[src]
fn document() -> Documentation
[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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> IntoResult<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut 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>,