This documentation is for version v1.3.0 of NNG, but the latest released version is v1.8.0. see the documentation for v1.8.0 for the most up-to-date information.

SYNOPSIS

#include <nng/nng.h>
#include <nng/supplemental/tcp/tcp.h>

typedef struct nng_tcp_s nng_tcp;

DESCRIPTION

An nng_tcp represents a connected stream. TCP stream objects can be used to send or receive data.

The nng_tcp object is used for raw TCP connections, and should not be confused with a pipe object created using the nng_tcp(7) transport.
Most NNG applications should not use this, but instead use the nng_tcp(7) transport instead.

These objects are created either establishing an outgoing connection with nng_tcp_dialer_dial() or by accepting in incoming connection with nng_tcp_listener_accept().

TCP connections are byte streams, and are “reliable” in that data will not be delivered out of order, or with portions missing.

Data can be sent using nng_tcp_send() or received with nng_tcp_recv().

When the connection is no longer needed, it should be freed with nng_tcp_free().

It is possible to close the connection, without freeing it, by using nng_tcp_close().

Options

The following options are applicable to TCP connections, and may be accessed using the nng_tcp_getopt() and nng_tcp_setopt() functions.

Other platform specific options may be available as well.