tcpin

package
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 28, 2026 License: MIT Imports: 13 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

TCP In node

Type: tcpIn
Category: Network

Receives raw TCP data (listen or connect).

Behavior

This node is registered as tcpIn and runs as part of a workflow. Its exact runtime behavior is implemented in node.go; this document summarizes the editor-facing purpose and configuration contract.

Configuration

Field Type Default Description
datamode string stream Output — stream: emit each chunk / delimited part; single: one message with the whole buffer at close; length: emit every Length bytes; timeout: flush the buffer after FlushMS ms of silence
datatype string utf8 Payload — utf8: string payload; buffer: raw bytes; base64: base64-encoded string
flushms integer Flush (ms) — Idle interval before the buffered data flushes in timeout mode
host string Host — Remote host for connect mode (default 127.0.0.1)
length integer Length — Chunk size for length mode
mode string Mode — Legacy alias of Type (listen=server, connect=client); ignored when Type is set
newline string Delimiter — Stream delimiter for utf8 payloads (escape sequences like \n allowed; empty = emit each chunk)
port integer Port — Listen port (listen mode) or remote port (connect mode)
server string server Type — server: accept connections on port; client: dial out to host:port (Node-RED 'server' field)
tls string TLS Config — Optional tlsConfig node; connect-mode dials are upgraded to TLS with that material
topic string Topic — Stamped on emitted messages as metadata topic
trim boolean false Re-attach Delimiter — Keep the delimiter attached to each emitted part

Implementation

  • node.go contains the executor, validation, schema, and registration.
  • editor.html contains the editor integration.
  • node_test.go, when present, contains behavioral tests.

Documentation

Overview

Package tcpin contains the tcpIn node implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TCPInConfig

type TCPInConfig struct {
	// Mode selects "listen" (accept connections on port) or
	// "connect" (dial out to host:port) — legacy alias of the
	// Node-RED "server" field; Server wins when set.
	Mode string `json:"mode"`
	// Server is the Node-RED connection selector: "server" listens
	// on Port, "client" dials Host:Port.
	Server string `json:"server"`
	// Host is the remote host for connect mode (default 127.0.0.1).
	Host string `json:"host"`
	// Port is the listen port (listen mode) or remote port (connect).
	Port int `json:"port"`
	// Datamode selects the output framing: "stream" (default —
	// emit each chunk, or each delimited part for utf8 with a
	// delimiter), "single" (one message with the whole buffer at
	// connection close), "length" (emit every Length bytes) or
	// "timeout" (flush the buffered data after FlushMS ms idle).
	Datamode string `json:"datamode"`
	// Datatype selects the payload type: "utf8" (string — default,
	// matching the previous always-string behavior), "buffer"
	// (raw []byte) or "base64" (base64-encoded string).
	Datatype string `json:"datatype"`
	// Newline is the stream delimiter for utf8 payloads — a pointer
	// so a blank-but-explicit "" (Node-RED 'no delimiter — emit each
	// chunk') is distinct from unset (legacy "\n" line mode).
	Newline *string `json:"newline"`
	// Trim re-attaches the delimiter to each emitted part
	// (Node-RED 're-attach' checkbox).
	Trim bool `json:"trim"`
	// Topic is stamped on emitted messages as metadata "topic".
	Topic string `json:"topic"`
	// Length is the fixed chunk size for datamode "length".
	Length int `json:"length"`
	// FlushMS is the idle flush interval (milliseconds) for
	// datamode "timeout".
	FlushMS int `json:"flushms"`
	// Base64 is a deprecated Node-RED field — decoded, unused.
	Base64 bool `json:"base64"`
	// TLS names a tlsConfig node in the same workflow; in connect
	// mode the dialed connection is upgraded to TLS with that material.
	TLS string `json:"tls"`
}

TCPInConfig holds configuration for the tcpIn node.

type TCPInNode

type TCPInNode struct {
	*nodebase.BaseNode
	// contains filtered or unexported fields
}

TCPInNode receives raw TCP data — either by listening for inbound connections or by connecting to a remote host. Received data is framed per the datamode (stream/single/length/timeout) and emitted downstream with the remote ip/port in Metadata. Accepted connections are registered in the workflow's shared tcpSessions map for tcpOut reply mode.

func NewTCPInNode

func NewTCPInNode(node nodestore.NodeInterface, config *TCPInConfig, host nodebase.NodeHost) *TCPInNode

NewTCPInNode creates a new tcpIn node

func (*TCPInNode) Execute

Execute activates the node: listen mode binds a socket and spawns an accept loop; connect mode dials and starts one reader goroutine.

func (*TCPInNode) Stop

func (n *TCPInNode) Stop() error

Stop shuts down the listener / outbound connection and every accepted session registered by this workflow's tcpIn nodebase.

func (*TCPInNode) Validate

func (n *TCPInNode) Validate() error

Validate checks the tcpIn node configuration

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL