IPC@CHIP Modbus library – API Documentation

Header image

Main page

int mbTCP_cl_connect ( MbHandle  handle,
const char *  ipAddrStr,
u16  port,
TCPKeepAliveOpt opt,
u16  timeoutMs,
int *  errorCode 

Opens a TCP socket and try to connect to a Modbus TCP server.

[in] handle : Handle returned by mbTCP_cl_init()
[in] ipAddrStr : Servers IPv4 address as dotted decimal string
[in] port : TCP port number
[in] opt : Pointer to TCP socket options, type TCPKeepAliveOpt
[out] errorCode : Output: Holds RTOS TCP/IP Socket API error code
[in] timeoutMs : Maximum time in [ms] to wait for connection
Result code:
> 0 Connection established
  Use the return value as connection handle number at further API function calls (e.g. mbTCP_cl_wr_regs).
-1: Invalid IP address string specified
-2: socket open error
-3: Switch socket to non blocking mode failed
-4: Connection error, timeout
-5: Fault, when setting socket options
In case of failures, the socket will be closed.
The "MODBUS MESSAGING IMPLEMENTATION GUIDE" recommends registered port 502 for Modbus TCP servers.

Top of page | Main page

Copyright © 2017 Beck IPC GmbH
Generated on Thu Mar 9 18:00:33 2017 by Doxygen 1.6.1