OSMQ
v2.0.1

osmq.net
Class SocketStreamFilter

java.lang.Object
  extended byosmq.util.ExceptionListenerBase
      extended byosmq.util.ExceptionListenerImpl
          extended byosmq.net.SocketStreamFilter
All Implemented Interfaces:
ExceptionListener
Direct Known Subclasses:
ClientStream

public class SocketStreamFilter
extends ExceptionListenerImpl

Client stream for communicating with a remote service.


Constructor Summary
SocketStreamFilter(DiscoverySocket ds)
           
SocketStreamFilter(RemoteService es, ExceptionListener listener)
           
SocketStreamFilter(java.net.Socket socket, boolean binarymode)
           
 
Method Summary
 void close()
           
 void flush()
           
 java.net.InetAddress getInetAddress()
           
 long getWrittenCount()
          Returns the number of message writes
 boolean isOpen()
           
 void println(java.lang.String s)
          Print a string to the socket stream
 void printlnCounted(java.lang.String s)
          Print a string to the socket stream and increments the write count
 byte[] readBytes()
          Reads the next byte array from the socket input stream.
 java.lang.String readln()
          Reads the next String from the socket input stream.
 void setSocket(DiscoverySocket socket)
          This method may be called to replace an exisiting socket.
 void setSocket(java.net.Socket socket, boolean binarymode)
          This method may be called to replace an exisiting socket.
 void writeBytes(byte[] v)
          Write an array of bytes to the socket stream
 void writeBytesCounted(byte[] v)
          Write an array of bytes to the socket stream and increments the write count
 void writeNull()
          Used to test active socket connections.
 
Methods inherited from class osmq.util.ExceptionListenerImpl
onException
 
Methods inherited from class osmq.util.ExceptionListenerBase
getExceptionListener, setExceptionListener
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SocketStreamFilter

public SocketStreamFilter(java.net.Socket socket,
                          boolean binarymode)
                   throws java.io.IOException

SocketStreamFilter

public SocketStreamFilter(DiscoverySocket ds)
                   throws java.io.IOException

SocketStreamFilter

public SocketStreamFilter(RemoteService es,
                          ExceptionListener listener)
                   throws java.io.IOException
Method Detail

setSocket

public void setSocket(java.net.Socket socket,
                      boolean binarymode)
               throws java.io.IOException
This method may be called to replace an exisiting socket. This might be done by a client application if the remote server fails, and there is a need to connect to an alternate server.

Throws:
java.io.IOException

setSocket

public void setSocket(DiscoverySocket socket)
               throws java.io.IOException
This method may be called to replace an exisiting socket. This might be done by a client application if the remote server fails, and there is a need to connect to an alternate server.

Throws:
java.io.IOException

getWrittenCount

public long getWrittenCount()
Returns the number of message writes


printlnCounted

public void printlnCounted(java.lang.String s)
                    throws java.io.IOException
Print a string to the socket stream and increments the write count

Parameters:
s - the String to be printed
Throws:
java.io.IOException - if String size < 1 or there is a communications error

println

public void println(java.lang.String s)
             throws java.io.IOException
Print a string to the socket stream

Parameters:
s - the String to be printed
Throws:
java.io.IOException - if String size < 1 or there is a communications error

writeBytesCounted

public void writeBytesCounted(byte[] v)
                       throws java.io.IOException
Write an array of bytes to the socket stream and increments the write count

Parameters:
v - the bytes to be written
Throws:
java.io.IOException - if String size < 1 or there is a communications error

writeBytes

public void writeBytes(byte[] v)
                throws java.io.IOException
Write an array of bytes to the socket stream

Parameters:
v - the bytes to be written
Throws:
java.io.IOException - if String size < 1 or there is a communications error

writeNull

public void writeNull()
               throws java.io.IOException
Used to test active socket connections. This sends a value indicating a zero-sized string.

Throws:
java.io.IOException

readln

public java.lang.String readln()
                        throws java.io.IOException
Reads the next String from the socket input stream. This is a blocking read -- it waits indefinitely for the next String.

Note that the function ignores null length Strings.

Returns:
the value of the next byte packet as a String.
Throws:
java.io.IOException - if there is a communications failure.

readBytes

public byte[] readBytes()
                 throws java.io.IOException
Reads the next byte array from the socket input stream. This is a blocking read -- it waits indefinitely for the next byte array.

Note that the function ignores null array.

Returns:
the value of the next byte packet as a byte array.
Throws:
java.io.IOException - if there is a communications failure.

getInetAddress

public java.net.InetAddress getInetAddress()

isOpen

public boolean isOpen()

flush

public void flush()
           throws java.io.IOException
Throws:
java.io.IOException

close

public void close()

(c) 2000 - 2003 MQue Systems
All Rights Reserved