NN_DEVICE(3compat)

πŸ“¦ version 1.11, in alpine 3.24

hey bestie πŸ’– this is the NN_DEVICE(3compat) page from the NNG Reference Manual, and it’s giving legacy-compat realness. let’s get into it 🫢

🌸 NAME 🌸

nn_device β€” create forwarding device (compatible API) πŸ› οΈ

✨ SYNOPSIS ✨

#include <nanomsg/nn.h>

int nn_device(int sock1, int sock2);

πŸ’– DESCRIPTION πŸ’–

okay so nn_device() is used to create a forwarder. messages received on one of the two sockets, sock1 and sock2, are forwarded to the other one. it’s giving matchmaker energy, but for messages πŸ’Œ

Note πŸŽ€ this function is provided for API compatibility with legacy libnanomsg. consider using the relevant modern API instead. lowkey a β€œfor the archives” situation, bestie.

the two sockets must be compatible, and must be raw mode sockets. more detail about devices and how they can be used is available in the new style nng_device() documentation. go off, modern docs πŸ‘‘

πŸ¦‹ RETURN VALUES πŸ¦‹

this function blocks forever, fr fr. it will return -1 only when one of the sockets is closed or an error occurs. so don’t wait up for a cute little 0 πŸ˜­πŸ’…

🌈 ERRORS 🌈

  • EBADF β€” one of the two sockets is invalid or not open, or has (and yes, the original line stops right there β€” no cap, that’s the whole vibe 🫠)
  • EINVAL β€” the sockets are not compatible with each other, or not both raw.
  • ENOMEM β€” insufficient memory is available.

πŸŽ€ SEE ALSO πŸŽ€


okay that’s the whole page, bestie. source/version: NNG Reference Manual; date: 2026-01-13. mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from