File: modbus_set_socket.txt

package info (click to toggle)
libmodbus 3.0.6-2
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 660 kB
  • ctags: 314
  • sloc: ansic: 4,031; makefile: 145; sh: 1
file content (56 lines) | stat: -rw-r--r-- 1,027 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
modbus_set_socket(3)
====================


NAME
----
modbus_set_socket - set socket of the context


SYNOPSIS
--------
*void modbus_set_socket(modbus_t *'ctx', int 'socket');*


DESCRIPTION
-----------
The _modbus_set_socket()_ function shall set the socket or file descriptor in
the libmodbus context. This function is useful for managing multiple client
connections to the same server.


RETURN VALUE
------------
There is no return values.


EXAMPLE
-------
[source,c]
-------------------
ctx = modbus_new_tcp("127.0.0.1", 1502);
server_socket = modbus_tcp_listen(ctx, NB_CONNECTION);

FD_ZERO(&rdset);
FD_SET(server_socket, &rdset);

/* .... */

if (FD_ISSET(master_socket, &rdset)) {
    modbus_set_socket(ctx, master_socket);
    rc = modbus_receive(ctx, query);
    if (rc != -1) {
        modbus_reply(ctx, query, rc, mb_mapping);
    }
}
-------------------

SEE ALSO
--------
linkmb:modbus_get_socket[3]


AUTHORS
-------
The libmodbus documentation was written by Stéphane Raimbault
<stephane.raimbault@gmail.com>