modbus_tcp_pi_accept.txt 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. modbus_tcp_pi_accept(3)
  2. =======================
  3. NAME
  4. ----
  5. modbus_tcp_pi_accept - accept a new connection on a TCP PI Modbus socket (IPv6)
  6. SYNOPSIS
  7. --------
  8. *int modbus_tcp_pi_accept(modbus_t *'ctx', int *'s);*
  9. DESCRIPTION
  10. -----------
  11. The *modbus_tcp_pi_accept()* function shall extract the first connection on the
  12. queue of pending connections, create a new socket and store it in libmodbus
  13. context given in argument. If available, _accept4()_ with `SOCK_CLOEXEC` will be
  14. called instead of *accept()*.
  15. RETURN VALUE
  16. ------------
  17. The function shall return a new socket if successful.
  18. Otherwise it shall return -1 and set errno.
  19. EXAMPLE
  20. -------
  21. For detailed example, see unit-test-server.c source file in tests directory.
  22. [source,c]
  23. -------------------
  24. ...
  25. ctx = modbus_new_tcp_pi("::0", 502);
  26. s = modbus_tcp_pi_listen(ctx, 1);
  27. modbus_tcp_pi_accept(ctx, &s);
  28. ...
  29. close(s)
  30. modbus_free(ctx);
  31. -------------------
  32. SEE ALSO
  33. --------
  34. linkmb:modbus_tcp_pi_accept[3]
  35. linkmb:modbus_tcp_listen[3]
  36. linkmb:modbus_tcp_pi_listen[3]
  37. AUTHORS
  38. -------
  39. The libmodbus documentation was written by Stéphane Raimbault
  40. <stephane.raimbault@gmail.com>