NN_GET_STATISTIC(3)

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

πŸ’– NN_GET_STATISTIC(3) πŸ’–

okay bestie, welcome to nanomsg 1.2.2 β€” lemme tell you about the little function that lets you peek at your socket's ~numbers~ πŸ‘‘


✨ NAME ✨

nn_get_statistic β€” pull statistics out of a nanomsg socket, no cap πŸ“Š


🌸 SYNOPSIS 🌸

#include <nanomsg/nn.h>

uint64_t nn_get_statistic (int s, int statistic);

πŸ¦‹ DESCRIPTION πŸ¦‹

So basically this grabs the value of one specific statistic from your socket. That's it, that's the whole vibe. πŸ’…

Caution β€” the API itself is stable, but these statistics are for humans. Like, they exist so you can observe and debug stuff, okay? The actual stats and what they mean are unstable and can change without anyone telling you. So do not build a program that depends on any particular statistic existing, or on its value meaning anything. fr fr. πŸ™ˆ

The nanomsg core framework keeps these ones up to date. There may be other statistics hanging around too β€” those are undocumented, so don't try to read into them, literally just leave them alone. Also, not every statistic makes sense for every transport! For example, the nn_inproc(7) transport doesn't maintain any of the connection-related statistics at all. 🫢

  • NN_STAT_ESTABLISHED_CONNECTIONS β€” how many connections got successfully established that were started from this socket.
  • NN_STAT_ACCEPTED_CONNECTIONS β€” how many connections got successfully established that this socket accepted.
  • NN_STAT_DROPPED_CONNECTIONS β€” how many established connections this socket dropped. 😭
  • NN_STAT_BROKEN_CONNECTIONS β€” how many established connections this socket closed, usually because of protocol errors. πŸ’€
  • NN_STAT_CONNECT_ERRORS β€” how many errors this socket hit while trying to connect to a remote peer.
  • NN_STAT_BIND_ERRORS β€” how many errors this socket hit while trying to bind to a local address.
  • NN_STAT_ACCEPT_ERRORS β€” how many errors this socket hit while trying to accept a connection from a remote peer.
  • NN_STAT_CURRENT_CONNECTIONS β€” how many connections are established to this socket right now. ⭐
  • NN_STAT_MESSAGES_SENT β€” how many messages this socket sent. πŸ“€
  • NN_STAT_MESSAGES_RECEIVED β€” how many messages this socket received. πŸ“₯
  • NN_STAT_BYTES_SENT β€” how many bytes this socket sent.
  • NN_STAT_BYTES_RECEIVED β€” how many bytes this socket received.

πŸ”₯ RETURN VALUE πŸ”₯

If it worked, you get the value of the statistic. If it didn't, you get (uint64_t)-1. that's the whole deal πŸŽ€


πŸ’œ ERRORS πŸ’œ

  • EINVAL β€” that statistic is invalid or unsupported. nope, not a thing bestie.
  • EBADF β€” the socket you handed over is invalid.
  • ETERM β€” the library is terminating. it's over, it's done, we're shutting down. 🌈

🧚 EXAMPLE 🧚

val = nn_get_statistic (s, NN_STAT_MESSAGES_SENT);
if (val == 0)
    printf ("No messages have been sent yet.\n");

πŸ‘‘ SEE ALSO πŸ‘‘

nn_errno(3) nn_symbol(3) nanomsg(7)


πŸ“ AUTHORS πŸ“

Garrett D’Amore <garrett@damore.org> β€” ty king πŸ™‡β€β™€οΈ


and that's the page!! this one is from the nanomsg 1.2.2 manual, dated 2026-01-16, and it's literally called NN_GET_STATISTIC(3). go forth and count your messages bestie πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from