NNG_MSG_CHOP(3)

πŸ“¦
version 1.12.0 Β· 4 versions
, in ubuntu stonking

πŸ’– NNG_MSG_CHOP πŸ’–

okay bestie, so this is nng_msg_chop(3) from the NNG Reference Manual β€” the lil' family of functions that says "bye bye" to data at the end of a message body 🫢


✨ NAME ✨

nng_msg_chop β€” remove data from end of message body πŸ“


✨ SYNOPSIS ✨

#include <nng/nng.h>

int nng_msg_chop(nng_msg *msg, size_t size);
int nng_msg_chop_u16(nng_msg *msg, uint16_t *val16);
int nng_msg_chop_u32(nng_msg *msg, uint32_t *val32);
int nng_msg_chop_u64(nng_msg *msg, uint64_t *val64);

✨ DESCRIPTION ✨

so the nng_msg_chop() family? it's giving scissors but for messages βœ‚οΈβœ¨ These functions remove data from the end of the body of message msg. Not the front, bestie β€” the end. If you wanted the front, that's a whole other function, and yes it's in SEE ALSO, iykyk πŸ’…

here's the vibe breakdown:

  • the first one, nng_msg_chop(), removes size bytes. just... gone. bye πŸ’¨
  • the remaining ones remove 2, 4, or 8 bytes, and then stores them in the value (like val32) β€” but plot twist β€” after converting them from network-byte order (big-endian) to native byte order πŸ”„πŸ‘‘

so like, it doesn't just yeet the bytes into the void, it hands them to you all nicely converted. the way that it's both a delete AND a read? main character behavior, fr fr πŸ‘‘


✨ RETURN VALUES ✨

these functions return 0 on success, and non-zero otherwise πŸŽ€ (as is the way of Unix, no cap)


✨ ERRORS ✨

  • NNG_EINVAL β€” the message body is too short to remove the requested data 😭 like bestie you cannot chop what isn't there. there's just not enough message to go around.

✨ SEE ALSO ✨

nng_msg_alloc(3), nng_msg_append(3), nng_msg_body(3), nng_msg_free(3), nng_msg_insert(3), nng_msg_len(3), nng_msg_capacity(3), nng_msg_reserve(3), nng_msg_realloc(3), nng_msg_trim(3), nng_strerror(3), nng_msg(5), nng(7)

ok real talk for one sec 🫢 if your body is too short for whatever you asked to chop, you're getting NNG_EINVAL and nothing else happens. check your lengths first, diva. no guessing, just facts.

that's the whole page, babe ✨ go forth and chop responsibly 🌸

mwah πŸ’‹ β€” this was NNG_MSG_CHOP(3) from the NNG Reference Manual, dated 2026-06-30. slay, bye πŸ‘‘πŸ¦‹

πŸ“¦ where this page comes from