de.mud.jta.plugin
Class Socket

java.lang.Object
  extended by de.mud.jta.Plugin
      extended by de.mud.jta.plugin.Socket
All Implemented Interfaces:
SocketListener, FilterPlugin, PluginListener

public class Socket
extends Plugin
implements FilterPlugin, SocketListener

The socket plugin acts as the data source for networked operations.

Maintainer: Matthias L. Jugel

Version:
$Id: Socket.java 499 2005-09-29 08:24:54Z leo $
Author:
Matthias L. Jugel, Marcus Mei???ner

Field Summary
protected  java.io.InputStream in
           
protected  java.io.OutputStream out
           
protected  java.lang.String relay
           
protected  int relayPort
           
protected  java.net.Socket socket
           
 
Fields inherited from class de.mud.jta.Plugin
bus, id
 
Constructor Summary
Socket(PluginBus bus, java.lang.String id)
          Create a new socket plugin.
 
Method Summary
 void connect(java.lang.String host, int port)
          Connect to the host and port passed.
 void disconnect()
          Disconnect the socket and close the connection.
 FilterPlugin getFilterSource()
           
 int read(byte[] b)
          Read a block of data from the back end.
 void setFilterSource(FilterPlugin plugin)
          Set the source plugin where we get our data from and where the data sink (write) is.
 void write(byte[] b)
          Write a block of data to the back end.
 
Methods inherited from class de.mud.jta.Plugin
error, getId
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

socket

protected java.net.Socket socket

in

protected java.io.InputStream in

out

protected java.io.OutputStream out

relay

protected java.lang.String relay

relayPort

protected int relayPort
Constructor Detail

Socket

public Socket(PluginBus bus,
              java.lang.String id)
Create a new socket plugin.

Method Detail

connect

public void connect(java.lang.String host,
                    int port)
             throws java.io.IOException
Connect to the host and port passed. If the multi relayd (mrelayd) is used to allow connections to any host and the Socket.relay property is configured this method will connect to the relay first, send off the string "relay host port\n" and then the real connection will be published to be online.

Specified by:
connect in interface SocketListener
Throws:
java.io.IOException

disconnect

public void disconnect()
                throws java.io.IOException
Disconnect the socket and close the connection.

Specified by:
disconnect in interface SocketListener
Throws:
java.io.IOException

setFilterSource

public void setFilterSource(FilterPlugin plugin)
Description copied from interface: FilterPlugin
Set the source plugin where we get our data from and where the data sink (write) is. The actual data handling should be done in the read() and write() methods.

Specified by:
setFilterSource in interface FilterPlugin
Parameters:
plugin - the data source

getFilterSource

public FilterPlugin getFilterSource()
Specified by:
getFilterSource in interface FilterPlugin

read

public int read(byte[] b)
         throws java.io.IOException
Description copied from interface: FilterPlugin
Read a block of data from the back end.

Specified by:
read in interface FilterPlugin
Parameters:
b - the buffer to read the data into
Returns:
the amount of bytes actually read
Throws:
java.io.IOException

write

public void write(byte[] b)
           throws java.io.IOException
Description copied from interface: FilterPlugin
Write a block of data to the back end.

Specified by:
write in interface FilterPlugin
Parameters:
b - the buffer to be sent
Throws:
java.io.IOException