modbus_close.txt 869 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. modbus_close(3)
  2. ===============
  3. NAME
  4. ----
  5. modbus_close - close a Modbus connection
  6. SYNOPSIS
  7. --------
  8. *int modbus_close(*modbus_t 'ctx');*
  9. DESCRIPTION
  10. -----------
  11. The _modbus_close()_ function shall close the connection established with the
  12. backend set in the context.
  13. RETURN VALUE
  14. ------------
  15. The _modbus_close()_ function shall return 0 if successful. Otherwise it shall
  16. return -1 and set errno.
  17. EXAMPLE
  18. -------
  19. [source,c]
  20. -------------------
  21. modbus_t *ctx;
  22. ctx = modbus_new_tcp("127.0.0.1", 502);
  23. if (modbus_connect(ctx) == -1) {
  24. fprintf(stderr, "Connection failed: %s\n", modbus_strerror(errno));
  25. modbus_free(ctx);
  26. return -1;
  27. }
  28. modbus_close(ctx);
  29. modbus_free(ctx);
  30. -------------------
  31. SEE ALSO
  32. --------
  33. linkmb:modbus_connect[3]
  34. AUTHORS
  35. -------
  36. The libmodbus documentation was written by Stéphane Raimbault
  37. <stephane.raimbault@gmail.com>