Skip to main content

Source TCP

Purpose

Defines the parameters for receiving data over a TCP connection.

TCP is a connection-oriented (stateful) protocol — unlike UDP, a TCP connection is established before data transfer begins, and both endpoints maintain state throughout the session. This makes TCP suitable for reliable, ordered data streams where message boundaries need to be preserved.

This Asset can be used by:

Asset typeLink
Input ProcessorsStream Input Processor
Output ProcessorsStream Output Processor

Prerequisite

None. The TCP Source defines its own connection parameters directly — no separate Connection asset is required.

Configuration

Name & Description

  • Name : Name of the Asset. Spaces are not allowed in the name.

  • Description : Enter a description.

Inheritance chain of this Asset — If this Asset extends another, the inheritance chain is shown here. Click to navigate to any parent Asset in the chain.

Asset Usage: If the Asset is used by other Assets, the Asset Usage box shows how many times this Asset is used and which parts are referencing it. Otherwise it is not shown. Click to expand and then click to follow, if any.

Required Roles

In case you are deploying to a Cluster which is running (a) Reactive Engine Nodes which have (b) specific Roles configured, then you can restrict use of this Asset to those Nodes with matching roles. If you want this restriction, then enter the names of the Required Roles here. Otherwise, leave empty to match all Nodes (no restriction).

Host

  • Bind host : The network interface address on which the TCP Source listens. Leave empty to bind to all interfaces.
  • Bind port : The TCP port number on which to listen for incoming connections.

Advanced Parameters

  • Connection backlog : Number of pending connections the operating system holds in the queue while waiting for acceptance. Increase this value if many clients connect simultaneously.
  • Receive buffer size [bytes] : Size of the socket's receive buffer in bytes. Set to 0 to use the operating system default. Set to a specific value to control memory usage for high-throughput scenarios.
  • Idle timeout [sec] : Number of seconds after which an idle connection is automatically closed. If 0, connections are held open indefinitely.

Example: IoT Sensor Data over TCP

This example shows how to receive continuous temperature and humidity readings from IoT sensors connected over TCP.

Incoming Data Format

Each sensor sends newline-delimited JSON records:

{"sensor_id":"SENS-001","timestamp":"2026-03-27T08:00:00Z","temperature":22.4,"humidity":61.2}
{"sensor_id":"SENS-001","timestamp":"2026-03-27T08:00:05Z","temperature":22.5,"humidity":61.0}
{"sensor_id":"SENS-002","timestamp":"2026-03-27T08:00:00Z","temperature":18.7,"humidity":74.1}

Each line is a complete, independent JSON object. A newline character (\n) acts as the record boundary — no special framing is needed beyond that.

TCP Source Configuration

SettingValueReason
Bind hostacme.sensor.hostHostname of the machine running the Reactive Engine
Bind port9000Fixed port number — sensors are configured to connect here
Connection backlog50Queue depth for incoming connection requests
Receive buffer size6553664 KB socket receive buffer
Idle timeout3005-minute idle timeout — closes dead connections

Workflow Wiring

  1. TCP Source (IoTSensorSource) — binds to 0.0.0.0:9000 and accepts incoming sensor connections
  2. Stream Input Processor — reads the raw byte stream and forwards it to the next processor
  3. Mapping Processor — parses each newline-delimited JSON record, applies a schema, and maps fields to the output format
  4. File Sink — writes the processed records to a log file

Key Design Notes

  • No polling interval — TCP streams are push-based. The sensor pushes data as it is available; the engine reads continuously without asking.
  • Message boundaries — TCP itself is a stream protocol with no concept of record boundaries. Use a Format with a delimiter (e.g., newline) or a fixed-length framing to split the byte stream into logical records.
  • Connection handling — if a sensor disconnects and reconnects, layline.io handles the reconnection automatically. Set the Idle timeout to clean up sensors that stop sending without closing the connection properly.
  • Multiple sensors — multiple sensors can connect to the same port simultaneously. Each independent TCP connection carries its own stream of records.
Can't find what you are looking for?

Please note, that the creation of the online documentation is Work-In-Progress. It is constantly being updated. should you have questions or suggestions, please don't hesitate to contact us at support@layline.io .