Skip to main content

TCP Client

The ClientChannel class represents a communication channel on which you can make requests to server device. Channel presents the same interface once you create it, regardless of the underlying transport. You can create a TCP client channel using create_tcp method.

note

In Rust, you can use the spawn_tcp_client_task to create a channel and spawn the runner task in the current runtime. Otherwise, you can use create_tcp_handle_and_task and manually spawn the returned future when ready.

let channel = spawn_tcp_client_task(
HostAddr::ip(IpAddr::V4(Ipv4Addr::LOCALHOST), 502),
1,
default_retry_strategy(),
DecodeLevel::default(),
Some(Box::new(LoggingListener)),
);

Maximum Queued Requests

Each channel sends one request at a time and has a fixed-length buffer of requests to send.

Endpoint Configuration

The argument for the remote endpoint is a string in format the <host>:<port> where "host" must be one of the following:

  • IPv4 address
  • IPv6 address
  • DNS name (library will perform DNS name resolution internally)

Retry Strategy

A TCP channel tries to establish and maintain a connection as soon as it is created. To avoid flooding, reconnection delays are applied.

The RetryStrategy controls the rate at which the client retries failed connection attempts. The client uses exponential backoff when attempting to establish a connection. The delay between attempts doubles from min_delay up to max_delay.

Decode Level

See logging configuration page for more details.