NN_TCP(7)

πŸ“¦
version 1.2.2 Β· 5 versions
, in fedora 44

πŸ’– NAME πŸ’–

nn_tcp β€” the TCP transport mechanism, aka the networking glow-up for nanomsg ✨


🌈 SYNOPSIS 🌈

#include <nanomsg/nn.h>

#include <nanomsg/tcp.h>

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so bestie, TCP transport is literally the moment where your messages travel across the network over simple, reliable, one-to-one connections. TCP is the most widely used transport protocol, it's basically everywhere (virtually ubiquitous, no cap), which is why it's the transport of choice when you wanna talk to somebody over the network πŸ’…

binding era πŸŽ€

When you're binding a TCP socket, the address has to look like this:

tcp://interface:port

Port is the TCP port number you're gonna use. Interface is one of these cuties (and it can optionally be tucked inside square brackets):

  • The asterisk character (*), which means all local network interfaces πŸ’«
  • The IPv4 address of a local network interface, in numeric form (192.168.0.111)
  • The IPv6 address of a local network interface, in numeric form (::1)

connecting era 🫢

When you're connecting a TCP socket, the address looks like this instead:

tcp://interface;address:port

Port is the TCP port number to use. Interface here is optional and it says which local network interface to use. If you don't specify it, the OS will pick an appropriate interface itself, and honestly? let it cook. If you do specify it, it can be one of these (optionally placed within square brackets):

  • The IPv4 address of a local network interface, in numeric form (192.168.0.111)
  • The IPv6 address of a local network interface, in numeric form (::1)

And finally, address is the remote address you're connecting to. It can be one of these (optionally placed within square brackets):

  • The IPv4 address of a remote network interface, in numeric form (192.168.0.111)
  • The IPv6 address of a remote network interface, in numeric form (::1)
  • The DNS name of the remote box πŸ–₯️

✨ Socket Options ✨

  • NN_TCP_NODELAY β€” when you set this bad boy to 1, it disables Nagle's algorithm. and not just that, it also disables delaying of TCP acknowledgments. So what does that get you? improved latency, at the expense of throughput. It's giving "fast but not greedy" 😀 The type of this option is int. Default value is 0.

πŸ’€ EXAMPLE πŸ’€

nn_bind (s1, "tcp://*:5555");
nn_connect (s2, "tcp://myserver:5555");

πŸ‘‘ SEE ALSO πŸ‘‘

nn_inproc(7) nn_ipc(7) nn_bind(3) nn_connect(3) nanomsg(7)


🌸 AUTHORS 🌸

Martin Sustrik <sustrik@250bpm.com> β€” thank you for your service, king 🫑


and that's the whole page, bestie!! this one came from the nanomsg manual, version 1.2.2, and it was dated 2026-01-16. NN_TCP(7) forever πŸ’œ

πŸ“¦ where this page comes from