net.wimpi.modbus.io
Class ModbusTCPTransport

java.lang.Object
  extended by net.wimpi.modbus.io.ModbusTCPTransport
All Implemented Interfaces:
ModbusTransport

public class ModbusTCPTransport
extends Object
implements ModbusTransport

Class that implements the Modbus transport flavor.

Version:
@version@ (@date@)
Author:
Dieter Wimberger

Constructor Summary
ModbusTCPTransport(Socket socket)
          Constructs a new ModbusTransport instance, for a given Socket.
 
Method Summary
 void close()
          Closes the raw input and output streams of this ModbusTransport.
 ModbusRequest readRequest()
          Reads a ModbusRequest from the input stream of this ModbusTransport.
 ModbusResponse readResponse()
          Reads a ModbusResponse from the input stream of this ModbusTransport.
 void setSocket(Socket socket)
          Sets the Socket used for message transport and prepares the streams used for the actual I/O.
 void writeMessage(ModbusMessage msg)
          Writes a to the output stream of this ModbusTransport.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ModbusTCPTransport

public ModbusTCPTransport(Socket socket)
Constructs a new ModbusTransport instance, for a given Socket.

Parameters:
socket - the Socket used for message transport.
Method Detail

setSocket

public void setSocket(Socket socket)
               throws IOException
Sets the Socket used for message transport and prepares the streams used for the actual I/O.

Parameters:
socket - the Socket used for message transport.
Throws:
IOException - if an I/O related error occurs.

close

public void close()
           throws IOException
Description copied from interface: ModbusTransport
Closes the raw input and output streams of this ModbusTransport.

Specified by:
close in interface ModbusTransport
Throws:
IOException - if a stream cannot be closed properly.

writeMessage

public void writeMessage(ModbusMessage msg)
                  throws ModbusIOException
Description copied from interface: ModbusTransport
Writes a to the output stream of this ModbusTransport.

Specified by:
writeMessage in interface ModbusTransport
Parameters:
msg - a ModbusMessage.
Throws:
ModbusIOException - data cannot be written properly to the raw output stream of this ModbusTransport.

readRequest

public ModbusRequest readRequest()
                          throws ModbusIOException
Description copied from interface: ModbusTransport
Reads a ModbusRequest from the input stream of this ModbusTransport.

Specified by:
readRequest in interface ModbusTransport
Returns:
req the ModbusRequest read from the underlying stream.
Throws:
ModbusIOException - data cannot be read properly from the raw input stream of this ModbusTransport.

readResponse

public ModbusResponse readResponse()
                            throws ModbusIOException
Description copied from interface: ModbusTransport
Reads a ModbusResponse from the input stream of this ModbusTransport.

Specified by:
readResponse in interface ModbusTransport
Returns:
res the ModbusResponse read from the underlying stream.
Throws:
ModbusIOException - data cannot be read properly from the raw input stream of this ModbusTransport.


Copyright © 2010. All Rights Reserved.