Rename [gs]et_timeout_[begin|end] to [gs]et_[response|byte]_timeout
[libmodbus.git] / src / modbus-tcp.h
blobf23029b7f139971fe2d3bab6c59ead3c965b0d7e
1 /*
2 * Copyright © 2001-2010 Stéphane Raimbault <stephane.raimbault@gmail.com>
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser Public License for more details.
14 * You should have received a copy of the GNU Lesser Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #ifndef _MODBUS_TCP_H_
19 #define _MODBUS_TCP_H_
21 #include "modbus.h"
23 #if defined(_WIN32) && !defined(__CYGWIN__)
24 /* Win32 with MinGW, supplement to <errno.h> */
25 #include <winsock2.h>
26 #define ECONNRESET WSAECONNRESET
27 #define ECONNREFUSED WSAECONNREFUSED
28 #define ETIMEDOUT WSAETIMEDOUT
29 #define ENOPROTOOPT WSAENOPROTOOPT
30 #endif
32 #define MODBUS_TCP_DEFAULT_PORT 502
33 #define MODBUS_TCP_SLAVE 0xFF
35 /* Modbus_Application_Protocol_V1_1b.pdf Chapter 4 Section 1 Page 5
36 * TCP MODBUS ADU = 253 bytes + MBAP (7 bytes) = 260 bytes
38 #define MODBUS_TCP_MAX_ADU_LENGTH 260
40 modbus_t* modbus_new_tcp(const char *ip_address, int port);
41 int modbus_tcp_listen(modbus_t *ctx, int nb_connection);
42 int modbus_tcp_accept(modbus_t *ctx, int *socket);
44 modbus_t* modbus_new_tcp_pi(const char *node, const char *service);
45 int modbus_tcp_pi_listen(modbus_t *ctx, int nb_connection);
46 int modbus_tcp_pi_accept(modbus_t *ctx, int *socket);
48 #endif /* _MODBUS_TCP_H_ */