Skip to main content
Version: Next

TCP

The Transmission Control Protocol (TCP) offers a bi-directional byte stream between applications that communicate via IP. Tenzir supports writing to and reading from TCP sockets, both in server (listening) and client (connect) mode.

Use the IP address 0.0.0.0 to listen on all available network interfaces.

URL Support

The URL schemes tcp:// and tcps:// dispatch to load_tcp and save_tcp for seamless URL-style use via from and to.

SSL/TLS

To enable TLS, use tls=true. You can optionally pass a PEM-encoded certificate and private key via the certfile and keyfile options.

For testing purposes, you can quickly generate a self-signed certificate as follows:

openssl req -x509 -newkey rsa:2048 -keyout key_and_cert.pem -out key_and_cert.pem -days 365 -nodes

An easy way to test a TLS connection is to try connecting via OpenSSL:

openssl s_client 127.0.0.1:443

Examples

Read data by connecting to a remote TCP server

from "tcp://127.0.0.1:443", connect=true {
  read_json
}

Read data by listen on localhost with TLS enabled

from "tcp://127.0.0.1:443", tls=true, certfile="cert.pem", keyfile="key.pem" {
  read_json
}