1MODBUS_TCP_ACCEPT(3)           libmodbus Manual           MODBUS_TCP_ACCEPT(3)
2
3
4

NAME

6       modbus_tcp_accept - accept a new connection on a TCP Modbus socket
7       (IPv4)
8

SYNOPSIS

10       int modbus_tcp_accept(modbus_t *ctx, int *'s);
11

DESCRIPTION

13       The modbus_tcp_accept() function shall extract the first connection on
14       the queue of pending connections, create a new socket and store it in
15       libmodbus context given in argument. If available, accept4() with
16       SOCK_CLOEXEC will be called instead of accept().
17

RETURN VALUE

19       The function shall return a new socket if successful. Otherwise it
20       shall return -1 and set errno.
21

EXAMPLE

23       For detailed example, see unit-test-server.c source file in tests
24       directory.
25
26           ...
27
28           ctx = modbus_new_tcp("127.0.0.1", 502);
29           s = modbus_tcp_listen(ctx, 1);
30           modbus_tcp_accept(ctx, &s);
31
32           ...
33
34           close(s)
35           modbus_free(ctx);
36

SEE ALSO

38       modbus_tcp_pi_accept(3) modbus_tcp_listen(3) modbus_tcp_pi_listen(3)
39

AUTHORS

41       The libmodbus documentation was written by Stéphane Raimbault
42       <stephane.raimbault@gmail.com>
43
44
45
46libmodbus v3.1.6                  07/21/2022              MODBUS_TCP_ACCEPT(3)
Impressum