Class SslTcpConnection


  • public class SslTcpConnection
    extends AbstractTcpConnection
    A connection to a ssl tcp port

    Notes: InputStream.available() allways return 0 !
    Author:
    man
    • Constructor Detail

      • SslTcpConnection

        public SslTcpConnection​(java.lang.String ip,
                                int port)
        Construct a new SslSocketConnection class, with the given parameters.
        Parameters:
        ip - Device IP address
        port - Device port
      • SslTcpConnection

        public SslTcpConnection​(javax.net.ssl.SSLSocket socket,
                                boolean isServerConnection)
                         throws CommConnectionException
        Parameters:
        socket - the new @link SSLSocket}
        isServerConnection - set to true if the connection is created by accepting a client - so no reconnect is available
        Throws:
        CommConnectionException - throwed with error code ICommConnection.NOT_INITIALISED if the given socket is not connected
    • Method Detail

      • setTrustStoreFile

        public static void setTrustStoreFile​(java.lang.String trustStoreFile)
        Parameters:
        trustStoreFile - trust store file
      • setTrustStorePassword

        public static void setTrustStorePassword​(java.lang.String trustStorePassword)
        Parameters:
        trustStorePassword - trust store password
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • recv

        public void recv​(byte[] b,
                         int off,
                         int len)
                  throws CommConnectionException
        Description copied from class: ICommConnection
        Receives until buffer is filled or timeout occurrs.
        Overrides:
        recv in class ICommConnection
        Parameters:
        b - Byte array to fill
        off - Offset into array (it is filled beginning with the offset)
        len - Number of bytes to read.
        Throws:
        CommConnectionException - possible Errorcodes:
        • for TCP Connection:
          • CONNECTION_LOST
          • RECV_TIMEOUT
          • UNHANDLED_ERROR
          • NOT_INITIALISE
        • for USB Connection:
          • CONNECTION_LOST
          • RECV_TIMEOUT
          • UNHANDLED_ERROR
          • NOT_INITIALISE
        • for RS232 Connection:
          • CONNECTION_LOST
          • RECV_TIMEOUT
          • UNHANDLED_ERROR
          • NOT_INITIALISE
      • send

        public void send​(java.lang.String senddata)
                  throws CommConnectionException
        Description copied from class: ICommConnection
        Sends data to the connected device
        Overrides:
        send in class ICommConnection
        Parameters:
        senddata - data/command send to the the connected device
        Throws:
        CommConnectionException - possible Errorcodes:
        • for TCP Connection:
          • WRONG_PARAMETER
          • UNHANDLED_ERROR
          • NOT_INITIALISE
        • for USB Connection:
          • WRONG_PARAMETER
          • UNHANDLED_ERROR
          • NOT_INITIALISE
        • for RS232 Connection:
          • WRONG_PARAMETER
          • CONNECTION_LOST
          • UNHANDLED_ERROR
          • NOT_INITIALISE
      • receive

        public java.lang.StringBuilder receive​(int... terminators)
                                        throws CommConnectionException
        Description copied from class: ICommConnection
        Receives data from the connected device until one of the terminator signs is found. The result is returned as a StringBuilder for performance reasons.
        Overrides:
        receive in class ICommConnection
        Parameters:
        terminators - A list of terminator signs. Note that this may be a list of parameters or an array.
        Returns:
        a StringBuilder object, including the termination sign
        Throws:
        CommConnectionException - possible Errorcodes:
        • for TCP Connection:
          • CONNECTION_LOST
          • RECV_TIMEOUT
          • UNHANDLED_ERROR
          • NOT_INITIALISE
        • for USB Connection:
          • CONNECTION_LOST
          • RECV_TIMEOUT
          • UNHANDLED_ERROR
          • NOT_INITIALISE
        • for RS232 Connection:
          • CONNECTION_LOST
          • RECV_TIMEOUT
          • UNHANDLED_ERROR
          • NOT_INITIALISE