org.openmuc.jsml.tl
Class SML_TSAP

java.lang.Object
  extended by org.openmuc.jsml.tl.SML_TSAP

public class SML_TSAP
extends java.lang.Object

This class implements the SML Transport Layer Service Access Point (TSAP) for the use of SML over TCP/IP. It can be used by a client to create SML_TConnections as well as by a Server to listen for SML_TConnections


Constructor Summary
SML_TSAP()
          Use this constructor to create a client SML_TSAP that can be used to start a connection to a remote SML server.
SML_TSAP(int port, SML_TConnectionListener conListener)
          Use this constructor to create a server TSAP that can listen on a port.
SML_TSAP(int port, SML_TConnectionListener conListener, javax.net.ServerSocketFactory serverSocketFactory)
          Use this constructor to create a server TSAP that can listen on a port, with a specified ServerSocketFactory.
SML_TSAP(javax.net.SocketFactory socketFactory)
          Use this constructor to create a client SML_TSAP that can be used to start a connection to a remote SML server.
 
Method Summary
 SML_TConnection connectTo(java.net.InetAddress address, int port)
          Connect to a remote TSAP that is listening at the destination address.
protected  SML_TConnectionListener getConnectionListener()
           
 void setMaxConnections(int maxConnections)
          Set the maximum number of connections that are allowed in parallel by the Server SAP.
 void setMessageFragmentTimeout(int messageFragmentTimeout)
          Set the TConnection timeout for receiving data once the beginning of a message has been received.
 void setMessageTimeout(int messageTimeout)
          Set the TConnection timeout for waiting for the first byte of a new message.
 void startListening()
          Starts a new thread that listens on the configured port.
 void stopListening()
          Stop listing on the port.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SML_TSAP

public SML_TSAP()
Use this constructor to create a client SML_TSAP that can be used to start a connection to a remote SML server.


SML_TSAP

public SML_TSAP(javax.net.SocketFactory socketFactory)
Use this constructor to create a client SML_TSAP that can be used to start a connection to a remote SML server. You could pass an SSLSocketFactory to enable SSL.


SML_TSAP

public SML_TSAP(int port,
                SML_TConnectionListener conListener)
Use this constructor to create a server TSAP that can listen on a port.

Parameters:
port - the TCP-port that the ServerSocket will connect to. Should be between 1 and 65535.
conListener - the ConnectionListener that will be notified when remote TSAPs are connecting or the server stopped listening.

SML_TSAP

public SML_TSAP(int port,
                SML_TConnectionListener conListener,
                javax.net.ServerSocketFactory serverSocketFactory)
Use this constructor to create a server TSAP that can listen on a port, with a specified ServerSocketFactory.

Parameters:
port - the TCP-port that the ServerSocket will connect to. Should be between 1 and 65535.
conListener - the ConnectionListener that will be notified when remote TSAPs are connecting or the server stopped listening.
serverSocketFactory - The ServerSocketFactory to be used to create the ServerSocket
Method Detail

startListening

public void startListening()
                    throws java.io.IOException
Starts a new thread that listens on the configured port. This method is non-blocking.

Throws:
java.io.IOException

stopListening

public void stopListening()
Stop listing on the port. Stops the server thread.


setMaxConnections

public void setMaxConnections(int maxConnections)
Set the maximum number of connections that are allowed in parallel by the Server SAP.

Parameters:
maxConnections - the number of connections allowed (default is 100)

setMessageTimeout

public void setMessageTimeout(int messageTimeout)
                       throws java.net.SocketException
Set the TConnection timeout for waiting for the first byte of a new message. Default is 0 (unlimited)

Parameters:
messageTimeout - in milliseconds
Throws:
java.net.SocketException

setMessageFragmentTimeout

public void setMessageFragmentTimeout(int messageFragmentTimeout)
                               throws java.net.SocketException
Set the TConnection timeout for receiving data once the beginning of a message has been received. Default is 2000 (2seconds)

Parameters:
messageFragmentTimeout - in milliseconds
Throws:
java.net.SocketException

getConnectionListener

protected SML_TConnectionListener getConnectionListener()

connectTo

public SML_TConnection connectTo(java.net.InetAddress address,
                                 int port)
                          throws java.io.IOException
Connect to a remote TSAP that is listening at the destination address.

Parameters:
address - remote InetAddress
port - remote port
Returns:
the Connection Object
Throws:
java.io.IOException - is thrown if connection was unsuccessful.


Copyright © 2011. All Rights Reserved.