Modbus Software, Driver and Libraries
 Login 
Member of Modbus Organization

Have a Question?

We accept VISA, MasterCard, PayPal

30-day Money-Back Guarantee

MODBUS/TCP Protocol


Classes

class  MbusTcpMasterProtocol
 MODBUS/TCP Master Protocol. More...

TCP/IP Connection Management Functions

synchronized void com::focus_sw::fieldtalk::MbusTcpMasterProtocol.openProtocol (String hostName) throws IOException
 Connects to a MODBUS/TCP slave.
synchronized void com::focus_sw::fieldtalk::MbusTcpMasterProtocol.closeProtocol () throws IOException
 Closes a TCP/IP connection to a MODBUS/TCP slave and releases any system resources associated with the connection.
synchronized void com::focus_sw::fieldtalk::MbusTcpMasterProtocol.setPort (int portNo)
 Sets the TCP port number to be used by the protocol.
int com::focus_sw::fieldtalk::MbusTcpMasterProtocol.getPort ()
 Returns the TCP port number used by the protocol.
boolean com::focus_sw::fieldtalk::MbusTcpMasterProtocol.isOpen ()
 Returns whether currently connected or not.


Function Documentation

synchronized void openProtocol String  hostName  )  throws IOException [inherited]
 

Connects to a MODBUS/TCP slave.

This function establishes a logical network connection between master and slave. After a connection has been established data and control functions can be used. A TCP/IP connection should be closed if it is no longer needed.

Note:
The default time-out for the connection is 1000 ms.

The default TCP port number is 502.

Parameters:
hostName String with IP address or host name
Exceptions:
IOException An I/O error occured
ConnectException Connection refused by remote, no service listening
BindException Remote port in use
NoRouteToHostException No route to host
UnknownHostException Unknown host, e.g. wrong IP address or name
SecurityException Security violation
Note:
The time-out parameter does not apply for connection to a host. Instead the system's default time-out value will be used by the JVM.

synchronized void closeProtocol  )  throws IOException [virtual, inherited]
 

Closes a TCP/IP connection to a MODBUS/TCP slave and releases any system resources associated with the connection.

Exceptions:
IOException An I/O error occured

Implements MbusMasterFunctions.

synchronized void setPort int  portNo  )  [inherited]
 

Sets the TCP port number to be used by the protocol.

Remarks:
Usually the port number remains unchanged and defaults to 502. In this case no call to this function is necessary. However if the port number has to be different from 502 this function must be called before opening the connection with openConnection().
Parameters:
portNo Port number to be used when opening the connection (Range: 0 - 0xFFFF)
Exceptions:
IllegalStateException Conection is open
IllegalArgumentException Parameter is out of range

int getPort  )  [inherited]
 

Returns the TCP port number used by the protocol.

Returns:
Port number used by the protocol

boolean isOpen  )  [virtual, inherited]
 

Returns whether currently connected or not.

Return values:
true = connected
false = not connected

Implements MbusMasterFunctions.