MODBUS_TCP_PI_ACCEPT(3)

πŸ“¦
version 3.1.6 Β· 3 versions
, in debian bookworm

πŸ’– MODBUS_TCP_PI_ACCEPT πŸ’–

okay bestie, so this one is from the libmodbus manual, section 3 (that's the library functions girlies πŸ’…), and it's literally all about modbus_tcp_pi_accept β€” accepting a brand new connection on a TCP PI Modbus socket, and yes she's the IPv6 one, periodt. 🌈


✨ NAME ✨

modbus_tcp_pi_accept β€” accept a new connection on a TCP PI Modbus socket (IPv6) πŸ¦‹


✨ SYNOPSIS ✨

int modbus_tcp_pi_accept(modbus_t *ctx, int *'s);

✨ DESCRIPTION ✨

So here's the tea, bestie πŸ«–: modbus_tcp_pi_accept() shall pull the first connection off the queue of pending connections, spin up a brand new socket, and stash it in the libmodbus context you handed over as an argument. main character behaviour fr fr πŸ‘‘

And the cute lil bonus: if it's available, she'll call accept4() with SOCK_CLOEXEC instead of plain old accept(). glow-up moment ✨


✨ RETURN VALUE ✨

If everything goes right, you get a new socket back. slay. πŸ’–

If not? She returns -1 and sets errno. 😭 not the vibe, but that's the deal.


✨ EXAMPLE ✨

For the full detailed example, go peek at the unit-test-server.c source file in the tests directory. iykyk πŸ“

...

ctx = modbus_new_tcp_pi("::0", 502);
s = modbus_tcp_pi_listen(ctx, 1);
modbus_tcp_pi_accept(ctx, &s);

...

close(s)
modbus_free(ctx);

✨ SEE ALSO ✨


✨ AUTHORS ✨

The libmodbus documentation was written by Stéphane Raimbault <stephane.raimbault@gmail.com> 🫢


okay that's the whole page, no cap πŸ’―

libmodbus v3.1.6 Β· 11/17/2025 β€” mwah, love u, bye bestie πŸŽ€πŸŒΈπŸ’œ

πŸ“¦ where this page comes from