Bump version to 3.1.10
[libmodbus.git] / src / modbus-tcp.h
blob768d38c9dc8d2383fe8b079c1edd26b0938608c2
1 /*
2 * Copyright © Stéphane Raimbault <stephane.raimbault@gmail.com>
4 * SPDX-License-Identifier: LGPL-2.1-or-later
5 */
7 #ifndef MODBUS_TCP_H
8 #define MODBUS_TCP_H
10 #include "modbus.h"
12 MODBUS_BEGIN_DECLS
14 #if defined(_WIN32) && !defined(__CYGWIN__)
15 /* Win32 with MinGW, supplement to <errno.h> */
16 #include <winsock2.h>
17 #if !defined(ECONNRESET)
18 #define ECONNRESET WSAECONNRESET
19 #endif
20 #if !defined(ECONNREFUSED)
21 #define ECONNREFUSED WSAECONNREFUSED
22 #endif
23 #if !defined(ETIMEDOUT)
24 #define ETIMEDOUT WSAETIMEDOUT
25 #endif
26 #if !defined(ENOPROTOOPT)
27 #define ENOPROTOOPT WSAENOPROTOOPT
28 #endif
29 #if !defined(EINPROGRESS)
30 #define EINPROGRESS WSAEINPROGRESS
31 #endif
32 #endif
34 #define MODBUS_TCP_DEFAULT_PORT 502
35 #define MODBUS_TCP_SLAVE 0xFF
37 /* Modbus_Application_Protocol_V1_1b.pdf Chapter 4 Section 1 Page 5
38 * TCP MODBUS ADU = 253 bytes + MBAP (7 bytes) = 260 bytes
40 #define MODBUS_TCP_MAX_ADU_LENGTH 260
42 MODBUS_API modbus_t *modbus_new_tcp(const char *ip_address, int port);
43 MODBUS_API int modbus_tcp_listen(modbus_t *ctx, int nb_connection);
44 MODBUS_API int modbus_tcp_accept(modbus_t *ctx, int *s);
46 MODBUS_API modbus_t *modbus_new_tcp_pi(const char *node, const char *service);
47 MODBUS_API int modbus_tcp_pi_listen(modbus_t *ctx, int nb_connection);
48 MODBUS_API int modbus_tcp_pi_accept(modbus_t *ctx, int *s);
50 MODBUS_END_DECLS
52 #endif /* MODBUS_TCP_H */