1MODBUS_SET_SOCKET(3) Libmodbus Manual MODBUS_SET_SOCKET(3)
2
3
4
6 modbus_set_socket - set socket of the context
7
9 void modbus_set_socket(modbus_t *ctx, int socket);
10
12 The modbus_set_socket() function shall set the socket or file
13 descriptor in the libmodbus context. This function is useful for
14 managing multiple client connections to the same server.
15
17 There is no return values.
18
20 ctx = modbus_new_tcp("127.0.0.1", 1502);
21 server_socket = modbus_tcp_listen(ctx, NB_CONNECTION);
22
23 FD_ZERO(&rdset);
24 FD_SET(server_socket, &rdset);
25
26 /* .... */
27
28 if (FD_ISSET(master_socket, &rdset)) {
29 modbus_set_socket(ctx, master_socket);
30 rc = modbus_receive(ctx, query);
31 if (rc != -1) {
32 modbus_reply(ctx, query, rc, mb_mapping);
33 }
34 }
35
37 modbus_get_socket(3)
38
40 The libmodbus documentation was written by Stéphane Raimbault
41 <stephane.raimbault@gmail.com[1]>
42
44 1. stephane.raimbault@gmail.com
45 mailto:stephane.raimbault@gmail.com
46
47
48
49libmodbus 3.0.8 07/31/2019 MODBUS_SET_SOCKET(3)