1MODBUS_TCP_PI_ACCEPT(3) libmodbus Manual MODBUS_TCP_PI_ACCEPT(3)
2
3
4
6 modbus_tcp_pi_accept - accept a new connection on a TCP PI Modbus
7 socket (IPv6)
8
10 int modbus_tcp_pi_accept(modbus_t *ctx, int *'s);
11
13 The modbus_tcp_pi_accept() function shall extract the first connection
14 on the queue of pending connections, create a new socket and store it
15 in libmodbus context given in argument. If available, accept4() with
16 SOCK_CLOEXEC will be called instead of accept().
17
19 The function shall return a new socket if successful. Otherwise it
20 shall return -1 and set errno.
21
23 For detailed example, see unit-test-server.c source file in tests
24 directory.
25
26 ...
27
28 ctx = modbus_new_tcp_pi("::0", 502);
29 s = modbus_tcp_pi_listen(ctx, 1);
30 modbus_tcp_pi_accept(ctx, &s);
31
32 ...
33
34 close(s)
35 modbus_free(ctx);
36
38 modbus_tcp_pi_accept(3) modbus_tcp_listen(3) modbus_tcp_pi_listen(3)
39
41 The libmodbus documentation was written by Stéphane Raimbault
42 <stephane.raimbault@gmail.com>
43
44
45
46libmodbus v3.1.6 01/19/2023 MODBUS_TCP_PI_ACCEPT(3)