org.livetribe.slp.spi.net
Class TCPConnector

java.lang.Object
  extended by org.livetribe.slp.spi.net.NetworkConnector
      extended by org.livetribe.slp.spi.net.TCPConnector
Direct Known Subclasses:
SocketTCPConnector

public abstract class TCPConnector
extends NetworkConnector

Version:
$Rev: 200 $ $Date: 2006-08-09 14:17:10 +0200 (Wed, 09 Aug 2006) $

Field Summary
 
Fields inherited from class org.livetribe.slp.spi.net.NetworkConnector
logger
 
Constructor Summary
TCPConnector()
           
 
Method Summary
 int getMaxTCPMessageLength()
           
 int getTCPReadTimeout()
           
 boolean isTCPListening()
           
abstract  byte[] receive(Socket socket)
          Reads bytes containing an SLP message.
abstract  void reply(Socket socket, byte[] messageBytes)
          Sends the bytes containing an SLP message in reply to a previos request, via the given socket.
abstract  Socket send(byte[] messageBytes, InetAddress address, boolean closeSocket)
          Sends the bytes containing an SLP message.
 void setMaxTCPMessageLength(int maxTCPMessageLength)
           
 void setTCPListening(boolean tcpListening)
           
 void setTCPReadTimeout(int tcpReadTimeout)
           
 
Methods inherited from class org.livetribe.slp.spi.net.NetworkConnector
accept, addMessageListener, clearMessageListeners, createAcceptorPool, createAcceptors, createConnectionPool, destroyAcceptors, doStart, doStop, getInetAddresses, handle, isRunning, notifyMessageListeners, removeMessageListener, setAcceptorPool, setConnectionPool, setInetAddresses, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TCPConnector

public TCPConnector()
Method Detail

isTCPListening

public boolean isTCPListening()

setTCPListening

public void setTCPListening(boolean tcpListening)

getTCPReadTimeout

public int getTCPReadTimeout()

setTCPReadTimeout

public void setTCPReadTimeout(int tcpReadTimeout)

getMaxTCPMessageLength

public int getMaxTCPMessageLength()

setMaxTCPMessageLength

public void setMaxTCPMessageLength(int maxTCPMessageLength)

receive

public abstract byte[] receive(Socket socket)
                        throws MessageTooBigException,
                               SocketClosedException,
                               IOException
Reads bytes containing an SLP message.

Parameters:
socket - The socket to read the message from
Returns:
The bytes containing the SLP message
Throws:
MessageTooBigException - If the message length (as read from the SLP message header) is greater than the maximum message length
SocketClosedException - If the socket is closed by the client before the reading of all message bytes is completed
IOException - In case of communication errors

send

public abstract Socket send(byte[] messageBytes,
                            InetAddress address,
                            boolean closeSocket)
                     throws ConnectException,
                            IOException
Sends the bytes containing an SLP message.

Parameters:
messageBytes - The bytes containing the SLP message
address - The address to send the bytes to
closeSocket - True if the socket must be closed after the bytes have been sent
Returns:
The socket used to send the bytes, or null if the socket has been closed
Throws:
ConnectException - If the destination is not listening
IOException - In case of communication errors

reply

public abstract void reply(Socket socket,
                           byte[] messageBytes)
                    throws IOException
Sends the bytes containing an SLP message in reply to a previos request, via the given socket.

Parameters:
socket - The socket where the reply must be written to
messageBytes - The bytes containing the SLP message
Throws:
IOException - In case of communication errors


Copyright © 2006-2012 LiveTribe. All Rights Reserved.