Class Socket

  • All Implemented Interfaces:
    adams.core.AdditionalInformationHandler, adams.core.CleanUpHandler, adams.core.Destroyable, adams.core.GlobalInfoSupporter, adams.core.logging.LoggingLevelHandler, adams.core.logging.LoggingSupporter, adams.core.option.OptionHandler, adams.core.QuickInfoSupporter, adams.core.ShallowCopySupporter<AbstractRatOutput>, adams.core.SizeOfHandler, adams.core.Stoppable, adams.core.StoppableWithFeedback, adams.event.VariableChangeListener, RatOutput, Serializable

    public class Socket
    extends AbstractRatOutput
    Just outputs the data to the specified socket.
    Any incoming data that isn't a byte array gets converted to a string and its bytes (using the specified encoding) are then transmitted.

    -logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel)
        The logging level for outputting errors and debugging output.
        default: WARNING
     
    -address <adams.core.base.BaseHostname> (property: address)
        The address to connect to.
        default: 127.0.0.1:8000
     
    -encoding <adams.core.base.BaseCharset> (property: encoding)
        The type of encoding for sending the data.
        default: Default
     
    Author:
    FracPete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Detail

      • m_Address

        protected adams.core.base.BaseHostname m_Address
        the address to open.
      • m_Encoding

        protected adams.core.base.BaseCharset m_Encoding
        the encoding to use.
      • m_CloseAfterSend

        protected boolean m_CloseAfterSend
        whether to close the socket after sending data.
      • m_Socket

        protected transient Socket m_Socket
        the socket to use.
    • Constructor Detail

      • Socket

        public Socket()
    • Method Detail

      • globalInfo

        public String globalInfo()
        Returns a string describing the object.
        Specified by:
        globalInfo in interface adams.core.GlobalInfoSupporter
        Specified by:
        globalInfo in class adams.core.option.AbstractOptionHandler
        Returns:
        a description suitable for displaying in the gui
      • defineOptions

        public void defineOptions()
        Adds options to the internal list of options.
        Specified by:
        defineOptions in interface adams.core.option.OptionHandler
        Overrides:
        defineOptions in class adams.core.option.AbstractOptionHandler
      • setAddress

        public void setAddress​(adams.core.base.BaseHostname value)
        Sets the address.
        Parameters:
        value - the address
      • getAddress

        public adams.core.base.BaseHostname getAddress()
        Returns the address.
        Returns:
        the address
      • addressTipText

        public String addressTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setEncoding

        public void setEncoding​(adams.core.base.BaseCharset value)
        Sets the encoding to use.
        Parameters:
        value - the encoding, e.g. "UTF-8" or "UTF-16", empty string for default
      • getEncoding

        public adams.core.base.BaseCharset getEncoding()
        Returns the encoding to use.
        Returns:
        the encoding, e.g. "UTF-8" or "UTF-16", empty string for default
      • encodingTipText

        public String encodingTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setCloseAfterSend

        public void setCloseAfterSend​(boolean value)
        Sets whether to close the socket after sending the data.
        Parameters:
        value - true if to close socket
      • getCloseAfterSend

        public boolean getCloseAfterSend()
        Returns whether to close the socket after sending the data.
        Returns:
        true if to close socket
      • closeAfterSendTipText

        public String closeAfterSendTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • getQuickInfo

        public String getQuickInfo()
        Returns a quick info about the actor, which will be displayed in the GUI.
        Specified by:
        getQuickInfo in interface adams.core.QuickInfoSupporter
        Overrides:
        getQuickInfo in class AbstractRatOutput
        Returns:
        null if no info available, otherwise short string
      • doTransmit

        protected String doTransmit()
        Performs the actual transmission.
        Specified by:
        doTransmit in class AbstractRatOutput
        Returns:
        null if successful, otherwise error message
      • cleanUp

        public void cleanUp()
        Cleans up data structures, frees up memory.
        Specified by:
        cleanUp in interface adams.core.CleanUpHandler
        Overrides:
        cleanUp in class AbstractRatOutput