pub struct Config {
pub name: Option<String>,
pub listener_ip: Option<IpAddr>,
pub desired_listening_port: Option<u16>,
pub allow_random_port: bool,
pub fatal_io_errors: Vec<ErrorKind>,
pub max_connections: u16,
pub connection_timeout_ms: u16,
}
Expand description
The Tcp’s configuration. See the source of Config::default
for the defaults.
Fields§
§name: Option<String>
A user-friendly identifier of the Tcp. It is visible in the logs, where it allows Tcp instances to be distinguished more easily if multiple are run at the same time.
note: If set to None
when the configuration is initially created, it will be automatically assigned
(the string representation of) a sequential, zero-based numeric identifier. So this is essentially never
None
, in a running node.
listener_ip: Option<IpAddr>
The IP address the Tcp’s connection listener should bind to.
note: If set to None
, the Tcp will not listen for inbound connections at all.
desired_listening_port: Option<u16>
The desired listening port of the Tcp. If Config::allow_random_port
is set to true
, the Tcp
will attempt to bind its listener to a different port if the desired one is not available.
note: Config::listener_ip
must not be None
in order for it to have any effect.
allow_random_port: bool
Allow listening on a different port if Config::desired_listening_port
is unavailable.
note: Config::listener_ip
must not be None
in order for it to have any effect.
fatal_io_errors: Vec<ErrorKind>
The list of IO errors considered fatal and causing the connection to be dropped.
note: Tcp needs to implement the Reading
and/or Writing
protocol in order for it to have any effect.
max_connections: u16
The maximum number of active connections Tcp can maintain at any given time.
note: This number can very briefly be breached by 1 in case of inbound connection attempts. It can never be breached by outbound connection attempts, though.
connection_timeout_ms: u16
The maximum time (in milliseconds) allowed to establish a raw (before the Handshake
protocol) TCP connection.