Skip to main content

TCP Client Transport

Opens a TCP connection to a device or service: a Modbus TCP device, a serial-to-Ethernet converter, a test server. TCP carries a byte stream, so a codec splits it into messages (for example Modbus TCP, Line or Timeout).

Set Host and Port. TCP Nodelay sends small writes immediately instead of batching them, which most request/response protocols want; TCP Keepalive detects a peer that vanished without closing the connection. A Proxy URL (http://, socks5:// or socks5h://, optionally with user:pass@) routes the connection through a proxy.

If the connection cannot be made or the peer closes it, CycBox reconnects while the engine runs, waiting 1 s and doubling up to 10 s between attempts.

A TCP client connection to 127.0.0.1:1502 using the Modbus TCP codec.

Configuration reference​

Config IDtcp_client_transport
Selected byapp_transport = "tcp_client_transport"
PlatformsLinux, Windows, Android
LicenseFree

TCP network communication

Connection Configuration:

  • Host: Server IP address or hostname (supports both IPv4 and IPv6)
    • IPv4 examples: 127.0.0.1, 192.168.1.100
    • IPv6 examples: ::1, fe80::1, 2001:db8::1
  • Port: Server listening port number
  • Timeout: Connection timeout in milliseconds

TCP Options:

  • Enable KeepAlive: Enable TCP keep-alive mechanism to periodically send probe packets to detect if connection is still alive
    • Keep-alive time: 60 seconds
    • Probe interval: 10 seconds
  • Enable NoDelay: Disable Nagle's algorithm to send small packets immediately without buffering
    • Enable for low latency, suitable for real-time communication
    • Disable for higher throughput, suitable for bulk data transfer

Proxy (optional):

  • Leave empty for a direct connection. Supported proxy URL formats:
    • http://[user:pass@]host:port - HTTP CONNECT tunnel
    • socks5://[user:pass@]host:port - SOCKS5 (target hostname resolved locally)
    • socks5h://[user:pass@]host:port - SOCKS5 (target hostname resolved by the proxy)
SettingKeyTypeDefaultNotes
Hosttcp_client_transport_hostText (with presets)"127.0.0.1"Required
Porttcp_client_transport_portInteger (with presets)8080Required
Connection Timeout (ms)tcp_client_transport_timeoutInteger (with presets)5000Required
TCP Keepalivetcp_client_transport_keepaliveBooleantrueRequired
TCP Nodelaytcp_client_transport_nodelayBooleantrueRequired
Proxy URL (optional)tcp_client_transport_proxy_urlText (with presets)""

Setting details​

Host​

Presets (any other value can be entered):

ValueLabel
"127.0.0.1"localhost
"::1"localhost (IPv6)
"0.0.0.0"0.0.0.0
"::":: (IPv6 any)

Port​

Presets (any other value can be entered):

ValueLabel
80808080
90009000
30003000

Connection Timeout (ms)​

Presets (any other value can be entered):

ValueLabel
30003s
50005s
1000010s
3000030s

Proxy URL (optional)​

Presets (any other value can be entered):

ValueLabel
""No proxy
"http://proxy.example.com:8080"HTTP
"http://user:pass@proxy.example.com:8080"HTTP with auth
"socks5://proxy.example.com:1080"SOCKS5
"socks5://user:pass@proxy.example.com:1080"SOCKS5 with auth
"socks5h://proxy.example.com:1080"SOCKS5h (remote DNS)

Example config​

Default values as they appear in a saved configuration (for example the JSON block at the end of a cycbox/examples/*.lua file). Settings detected at runtime are omitted.

{
"app": {
"app_transport": "tcp_client_transport"
},
"tcp_client_transport": {
"tcp_client_transport_host": "127.0.0.1",
"tcp_client_transport_port": 8080,
"tcp_client_transport_timeout": 5000,
"tcp_client_transport_keepalive": true,
"tcp_client_transport_nodelay": true,
"tcp_client_transport_proxy_url": ""
}
}