public class TCPMasterConnection extends Object
| Constructor and Description |
|---|
TCPMasterConnection(InetAddress adr)
Constructs a TCPMasterConnection instance with a given
destination address.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes this TCPMasterConnection.
|
void |
connect()
Opens this TCPMasterConnection.
|
void |
connect(boolean useRtuOverTcp)
Opens this TCPMasterConnection.
|
boolean |
equals(Object obj)
A
TCPMasterConnection is equal if InetAddress & port are equal. |
InetAddress |
getAddress()
Returns the destination InetAddress of this
TCPMasterConnection.
|
AbstractModbusTransport |
getModbusTransport()
Returns the ModbusTransport associated with this
TCPMasterConnection.
|
NetworkInterface |
getNetworkInterface()
Gets the local NetworkInterface that this socket is bound
to.
|
int |
getPort()
Returns the destination port of this TCPMasterConnection.
|
int |
getTimeout()
Returns the timeout (msec) for this TCPMasterConnection.
|
boolean |
getUseUrgentData()
Gets the current setting of the flag which controls sending
urgent data to test a network connection.
|
int |
hashCode()
The unique value of the
TCPMasterConnection is calculated from the unique values of the
InetAddress & port |
boolean |
isConnected()
Tests if this TCPMasterConnection is connected.
|
boolean |
isUseRtuOverTcp()
Returns true if this connection is an RTU over TCP type
|
void |
setAddress(InetAddress adr)
Sets the destination InetAddress of this
TCPMasterConnection.
|
void |
setModbusTransport(ModbusTCPTransport trans)
Set the ModbusTransport associated with this
TCPMasterConnection
|
void |
setNetworkInterface(NetworkInterface networkInterface)
Sets the local NetworkInterface to bind to for this
TCPMasterConnection.
|
void |
setPort(int port)
Sets the destination port of this TCPMasterConnection.
|
void |
setProxy(Proxy proxy)
Sets the Proxy that this socket uses.
|
void |
setTimeout(int timeout)
Sets the timeout (msec) for this TCPMasterConnection.
|
void |
setUseRtuOverTcp(boolean useRtuOverTcp)
Sets the transport type to use
Normally set during the connection but can also be set after a connection has been established
|
void |
setUseUrgentData(boolean useUrgentData)
Set the flag which controls sending urgent data to test a
network connection.
|
public TCPMasterConnection(InetAddress adr)
adr - the destination InetAddress.public void connect()
throws Exception
Exception - if there is a network failure.public void connect(boolean useRtuOverTcp)
throws Exception
useRtuOverTcp - True if the RTU protocol should be used over TCPException - if there is a network failure.public boolean isConnected()
public void close()
public AbstractModbusTransport getModbusTransport()
public void setModbusTransport(ModbusTCPTransport trans)
trans - associated transportpublic int getTimeout()
public void setTimeout(int timeout)
timeout - - the timeout in milliseconds as an int.public int getPort()
public void setPort(int port)
port - the port number as int.public InetAddress getAddress()
public void setAddress(InetAddress adr)
adr - the destination address as InetAddress.public NetworkInterface getNetworkInterface()
public void setNetworkInterface(NetworkInterface networkInterface)
networkInterface - of the network card as NetworkInterface.public void setProxy(Proxy proxy)
proxy - the proxy as Proxy.public boolean getUseUrgentData()
public void setUseUrgentData(boolean useUrgentData)
useUrgentData - - Connections are testing using urgent data.public boolean isUseRtuOverTcp()
public void setUseRtuOverTcp(boolean useRtuOverTcp)
throws Exception
useRtuOverTcp - True if the transport should be interpreted as RTU over tCPException - If the connection is not validpublic boolean equals(Object obj)
TCPMasterConnection is equal if InetAddress & port are equal. There is no way how two
different TCPMasterConnections can use the same Socket at the same time, therefore this is good
enough for an equality testpublic int hashCode()
TCPMasterConnection is calculated from the unique values of the
InetAddress & portCopyright © 2025. All Rights Reserved.