jamod at SF

net.wimpi.modbus.io
Class ModbusTCPTransport

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

public class ModbusTCPTransport
extends java.lang.Object
implements ModbusTransport

Class that implements the Modbus transport flavor.

Version:
1.2rc1 (09/11/2004)
Author:
Dieter Wimberger

Constructor Summary
ModbusTCPTransport(java.net.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(java.net.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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ModbusTCPTransport

public ModbusTCPTransport(java.net.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(java.net.Socket socket)
               throws java.io.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:
java.io.IOException - if an I/O related error occurs.

close

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

Specified by:
close in interface ModbusTransport
Throws:
java.io.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.

jamod at SF

Copyright © 2002-2004 jamod development team.