Commit ffd2d691bfb2cc66a352782ca7484cf8ed0857fa
1 parent
6ca87014
Add documentation for modbus_tcp_pi_listen
Showing
2 changed files
with
65 additions
and
0 deletions
doc/Makefile.am
| @@ -46,6 +46,7 @@ MAN3 = \ | @@ -46,6 +46,7 @@ MAN3 = \ | ||
| 46 | modbus_set_socket.3 \ | 46 | modbus_set_socket.3 \ |
| 47 | modbus_strerror.3 \ | 47 | modbus_strerror.3 \ |
| 48 | modbus_tcp_listen.3 \ | 48 | modbus_tcp_listen.3 \ |
| 49 | + modbus_tcp_pi_listen.3 \ | ||
| 49 | modbus_write_and_read_registers.3 \ | 50 | modbus_write_and_read_registers.3 \ |
| 50 | modbus_write_bits.3 \ | 51 | modbus_write_bits.3 \ |
| 51 | modbus_write_bit.3 \ | 52 | modbus_write_bit.3 \ |
doc/modbus_tcp_pi_listen.txt
0 → 100644
| 1 | +modbus_tcp_pi_listen(3) | ||
| 2 | +======================= | ||
| 3 | + | ||
| 4 | + | ||
| 5 | +NAME | ||
| 6 | +---- | ||
| 7 | +modbus_tcp_pi_listen - create and listen a TCP PI Modbus socket (IPv6) | ||
| 8 | + | ||
| 9 | + | ||
| 10 | +SYNOPSIS | ||
| 11 | +-------- | ||
| 12 | +*int modbus_tcp_pi_listen(modbus_t *'ctx', int 'nb_connection');* | ||
| 13 | + | ||
| 14 | + | ||
| 15 | +DESCRIPTION | ||
| 16 | +----------- | ||
| 17 | +The _modbus_tcp_pi_listen()_ function shall create a socket and listen for | ||
| 18 | +'nb_connection' incoming connections. | ||
| 19 | + | ||
| 20 | + | ||
| 21 | +RETURN VALUE | ||
| 22 | +------------ | ||
| 23 | +The _modbus_tcp_listen()_ function shall return a new socket if | ||
| 24 | +successful. Otherwise it shall return -1 and set errno. | ||
| 25 | + | ||
| 26 | + | ||
| 27 | +EXAMPLE | ||
| 28 | +------- | ||
| 29 | + | ||
| 30 | +For detailed examples, see source files in tests directory: | ||
| 31 | + | ||
| 32 | +- unit-test-server.c, simple but handle only one connection | ||
| 33 | + | ||
| 34 | +[source,c] | ||
| 35 | +------------------- | ||
| 36 | +... | ||
| 37 | + | ||
| 38 | +ctx = modbus_new_tcp_pi("::0", "502"); | ||
| 39 | +s = modbus_tcp_pi_listen(ctx, 1); | ||
| 40 | +modbus_tcp_pi_accept(ctx, &s); | ||
| 41 | + | ||
| 42 | +for (;;) { | ||
| 43 | + rc = modbus_receive(ctx, query); | ||
| 44 | + modbus_replay(ctx, query, rc, mb_mapping); | ||
| 45 | +} | ||
| 46 | +... | ||
| 47 | + | ||
| 48 | +mclose(s); | ||
| 49 | +modbus_free(ctx); | ||
| 50 | +------------------- | ||
| 51 | + | ||
| 52 | +- bandwith-server-many-up.c, handles several connections at once | ||
| 53 | + | ||
| 54 | + | ||
| 55 | +SEE ALSO | ||
| 56 | +-------- | ||
| 57 | +linkmb:modbus_tcp_pi_accept[3] | ||
| 58 | +linkmb:modbus_tcp_accept[3] | ||
| 59 | +linkmb:modbus_tcp_listen[3] | ||
| 60 | + | ||
| 61 | +AUTHORS | ||
| 62 | +------- | ||
| 63 | +The libmodbus documentation was written by Stéphane Raimbault | ||
| 64 | +<stephane.raimbault@gmail.com> |