public class ModbusTCPTransport extends AbstractModbusTransport
| Constructor and Description |
|---|
ModbusTCPTransport()
Default constructor
|
ModbusTCPTransport(Socket socket)
Constructs a new ModbusTransport instance, for a given
Socket.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the raw input and output streams of
this ModbusTransport.
|
ModbusTransaction |
createTransaction()
Creates a Modbus transaction for the underlying transport.
|
long |
getLastActivityTimestamp() |
ModbusRequest |
readRequest(AbstractModbusListener listener)
Reads a ModbusRequest from the
input stream of this ModbusTransport.
|
ModbusResponse |
readResponse()
Reads a ModbusResponse from the
input stream of this ModbusTransport.
|
void |
setHeadless()
Set the transport to be headless
|
void |
setHeadless(boolean headless)
Set the transport to be headless
|
void |
setMaster(TCPMasterConnection master)
Sets the master connection for the transport to use
|
void |
setSocket(Socket socket)
Sets the Socket used for message transport and prepares the
streams used for the actual I/O.
|
void |
setTimeout(int time)
Set the socket timeout
|
void |
writeRequest(ModbusRequest msg)
Writes a ModbusMessage to the
output stream of this ModbusTransport.
|
void |
writeResponse(ModbusResponse msg)
Writes a ModbusResponseMessage to the
output stream of this ModbusTransport.
|
public ModbusTCPTransport()
public ModbusTCPTransport(Socket socket)
socket - the Socket used for message transport.public void setSocket(Socket socket) throws IOException
socket - the Socket used for message transport.IOException - if an I/O related error occurs.public void setHeadless()
public void setHeadless(boolean headless)
headless - True if headlesspublic void setMaster(TCPMasterConnection master)
master - Masterpublic void setTimeout(int time)
AbstractModbusTransportsetTimeout in class AbstractModbusTransporttime - Timeout in millisecondspublic long getLastActivityTimestamp()
System.nanoTime()public void close()
throws IOException
AbstractModbusTransportclose in class AbstractModbusTransportIOException - if a stream
cannot be closed properly.public ModbusTransaction createTransaction()
AbstractModbusTransportcreateTransaction in class AbstractModbusTransportpublic void writeResponse(ModbusResponse msg) throws ModbusIOException
AbstractModbusTransportwriteResponse in class AbstractModbusTransportmsg - a ModbusMessage.ModbusIOException - data cannot be
written properly to the raw output stream of
this ModbusTransport.public void writeRequest(ModbusRequest msg) throws ModbusIOException
AbstractModbusTransportwriteRequest in class AbstractModbusTransportmsg - a ModbusMessage.ModbusIOException - data cannot be
written properly to the raw output stream of
this ModbusTransport.public ModbusRequest readRequest(AbstractModbusListener listener) throws ModbusIOException
AbstractModbusTransportreadRequest in class AbstractModbusTransportlistener - Listener the request was received byModbusIOException - data cannot be
read properly from the raw input stream of
this ModbusTransport.public ModbusResponse readResponse() throws ModbusIOException
AbstractModbusTransportreadResponse in class AbstractModbusTransportModbusIOException - data cannot be
read properly from the raw input stream of
this ModbusTransport.Copyright © 2025. All Rights Reserved.