NNG_MSG_CHOP(3)
π 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
- ubuntu stonking: libnng-dev 1.12.0-1 Β· MIT OR Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms