org.livetribe.slp.spi.net
Class SocketTCPConnector

java.lang.Object
  extended by org.livetribe.slp.spi.net.NetworkConnector
      extended by org.livetribe.slp.spi.net.TCPConnector
          extended by org.livetribe.slp.spi.net.SocketTCPConnector

public class SocketTCPConnector
extends TCPConnector

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
SocketTCPConnector()
           
 
Method Summary
protected  Runnable[] createAcceptors()
           
protected  void destroyAcceptors()
           
 int getPort()
           
 byte[] receive(Socket socket)
          Reads bytes containing an SLP message.
 void reply(Socket socket, byte[] messageBytes)
          Sends the bytes containing an SLP message in reply to a previos request, via the given socket.
 Socket send(byte[] messageBytes, InetAddress address, boolean closeSocket)
          Sends the bytes containing an SLP message.
 void setPort(int port)
           
 
Methods inherited from class org.livetribe.slp.spi.net.TCPConnector
getMaxTCPMessageLength, getTCPReadTimeout, isTCPListening, setMaxTCPMessageLength, setTCPListening, setTCPReadTimeout
 
Methods inherited from class org.livetribe.slp.spi.net.NetworkConnector
accept, addMessageListener, clearMessageListeners, createAcceptorPool, createConnectionPool, 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

SocketTCPConnector

public SocketTCPConnector()
Method Detail

getPort

public int getPort()

setPort

public void setPort(int port)

createAcceptors

protected Runnable[] createAcceptors()
                              throws IOException
Specified by:
createAcceptors in class NetworkConnector
Throws:
IOException

destroyAcceptors

protected void destroyAcceptors()
                         throws IOException
Specified by:
destroyAcceptors in class NetworkConnector
Throws:
IOException

receive

public byte[] receive(Socket socket)
               throws MessageTooBigException,
                      SocketClosedException,
                      IOException
Description copied from class: TCPConnector
Reads bytes containing an SLP message.

Specified by:
receive in class TCPConnector
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 Socket send(byte[] messageBytes,
                   InetAddress address,
                   boolean closeSocket)
            throws ConnectException,
                   IOException
Description copied from class: TCPConnector
Sends the bytes containing an SLP message.

Specified by:
send in class TCPConnector
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 void reply(Socket socket,
                  byte[] messageBytes)
           throws IOException
Description copied from class: TCPConnector
Sends the bytes containing an SLP message in reply to a previos request, via the given socket.

Specified by:
reply in class TCPConnector
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.