NN_SOCKET(3compat)

πŸ“¦ version 1.11, in alpine 3.24

πŸ’… NN_SOCKET (3compat)

okay so real talk, this is the nn_socket page from the NNG Reference Manual β€” the legacy-compat corner of the house 🏠✨


🌸 NAME

nn_socket β€” create a socket (compatible API). that's it, that's the whole vibe πŸŽ€


✨ SYNOPSIS

#include <nanomsg/nn.h>

int nn_socket(int af, int proto);

πŸ’– DESCRIPTION

so nn_socket() literally makes you a socket using the address family af and the protocol proto, then hands it right back to you 🫢 slay.

🚨 note bestie: this function exists purely for API compatibility with legacy libnanomsg. like, consider using the relevant modern API instead, fr fr. it's giving "retro chic" but the modern one is the main character πŸ‘‘
⚠️ important, no cap: mixing the compatibility API and the modern API is not supported on a given socket. pick a lane, bestie πŸ’…
πŸ’€ also note: some protocols, transports, and features are only available in the modern API. so if something's missing, that's why 😭

the address family af can be one of two values:

  • AF_SP β€” normal socket 🌈
  • AF_SP_RAW β€” raw mode socket πŸ”₯

the protocol tells you which protocol to use when creating the socket. the following protocols are defined:

  • NN_PAIR β€” Pair protocol 🧚
  • NN_PUB β€” Publisher protocol πŸ“’
  • NN_SUB β€” Subscriber protocol πŸ“
  • NN_REQ β€” Requestor protocol πŸ™‹
  • NN_REP β€” Replier protocol πŸ’¬
  • NN_PUSH β€” Push protocol ➑️
  • NN_PULL β€” Pull protocol ⬅️
  • NN_SURVEYOR β€” Surveyor protocol πŸ“‹
  • NN_RESPONDENT β€” Respondent protocol πŸ—£οΈ
  • NN_BUS β€” Bus protocol 🚌

πŸ‘‘ RETURN VALUES

this function returns a valid socket number on success πŸ’–, and -1 on failure 😭.


πŸ”₯ ERRORS

  • ENOMEM β€” insufficient memory is available. the vibes are out of RAM πŸ’€
  • ENOTSUP β€” the protocol is not supported. nope, not that one πŸ™ˆ
  • ETERM β€” the library is shutting down. it's logging off, respectfully 🫑

πŸ¦‹ SEE ALSO

nng_socket(5), nn_close(3compat), nn_errno(3compat), nng_compat(3compat), nng(7)


and that's the whole page, bestie πŸŽ€ go forth and socket responsibly ✨

πŸ“Œ source/version: the NNG Reference Manual β€” page NN_SOCKET(3compat) β€” dated 2026-01-13. iykyk πŸ’œ

πŸ“¦ where this page comes from