Package gurux.net

Class GXNet

  • All Implemented Interfaces:
    gurux.common.IGXMedia, gurux.common.IGXMedia2, AutoCloseable

    public class GXNet
    extends Object
    implements gurux.common.IGXMedia2, AutoCloseable
    The GXNet component determines methods that make the communication possible using Internet.
    • Constructor Detail

      • GXNet

        public GXNet()
        Constructor.
      • GXNet

        public GXNet​(NetworkType networkType,
                     String name,
                     int portNo)
        Client Constructor.
        Parameters:
        networkType - Used protocol.
        name - Host name.
        portNo - Client port number.
      • GXNet

        public GXNet​(NetworkType networkType,
                     int portNo)
        Constructor used when server is started.
        Parameters:
        networkType - Used protocol.
        portNo - Server port.
    • Method Detail

      • attach

        public final GXNet attach​(String address)
        Attach TCP/IP connection. This can be used in server side if server want to start communicating with client using synchronous communication. Close connection after use.
        Parameters:
        address - cliend address to connect.
        Returns:
        Attached connection.
      • getTrace

        public final gurux.common.enums.TraceLevel getTrace()
        Specified by:
        getTrace in interface gurux.common.IGXMedia
      • setTrace

        public final void setTrace​(gurux.common.enums.TraceLevel value)
        Specified by:
        setTrace in interface gurux.common.IGXMedia
      • getConfigurableSettings

        public final int getConfigurableSettings()
        Specified by:
        getConfigurableSettings in interface gurux.common.IGXMedia
      • setConfigurableSettings

        public final void setConfigurableSettings​(int value)
        Specified by:
        setConfigurableSettings in interface gurux.common.IGXMedia
      • properties

        public final boolean properties​(JFrame parent)
        Specified by:
        properties in interface gurux.common.IGXMedia
      • aboutBox

        public final void aboutBox()
        Displays the copyright of the control, user license, and version information, in a dialog box.
      • send

        public final void send​(Object data,
                               String target)
                        throws Exception
        Specified by:
        send in interface gurux.common.IGXMedia
        Parameters:
        target - IP address of the receiver (optional). Reply data is received through OnReceived event.
        Throws:
        Exception
      • open

        public final void open()
                        throws Exception
        Opens the connection. Protocol, Port and HostName must be set, before calling the Open method.
        Specified by:
        open in interface gurux.common.IGXMedia
        Throws:
        Exception
        See Also:
        port, hostName, protocol, server, close()
      • close

        public final void close()
        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface gurux.common.IGXMedia
      • isOpen

        public final boolean isOpen()
        Specified by:
        isOpen in interface gurux.common.IGXMedia
      • getProtocol

        public final NetworkType getProtocol()
        Retrieves the used protocol.
        Returns:
        Protocol in use.
      • setProtocol

        public final void setProtocol​(NetworkType value)
        Sets the used protocol.
        Parameters:
        value - Used protocol.
      • getHostName

        public final String getHostName()
        Retrieves the name or IP address of the host.
        Returns:
        The name of the host.
        See Also:
        open(), port, protocol
      • setHostName

        public final void setHostName​(String value)
        Sets the name or IP address of the host.
        Parameters:
        value - The name of the host.
      • getPort

        public final int getPort()
        Retrieves or sets the host or server port number.
        Returns:
        Host or server port number.
        See Also:
        open(), hostName, protocol
      • setPort

        public final void setPort​(int value)
        Retrieves or sets the host or server port number.
        Parameters:
        value - Host or server port number
        See Also:
        open(), hostName, protocol
      • getServer

        public final boolean getServer()
        Is server mode used.
        Returns:
        Is server mode used.
        See Also:
        open()
      • setServer

        public final void setServer​(boolean value)
        Is server mode used.
        Parameters:
        value - Is server mode used.
        See Also:
        open()
      • getConnectionWaitTime

        public final int getConnectionWaitTime()
        Gets how long (milliseconds) server answer is waited when connection is made. Operating system time is used if value is zero.
        Returns:
        Wait time in milliseconds.
      • setConnectionWaitTime

        public final void setConnectionWaitTime​(int value)
        Sets how long (milliseconds) server answer is waited when connection is made. Operating system time is used if value is zero.
        Parameters:
        value - Wait time in milliseconds.
      • receive

        public final <T> boolean receive​(gurux.common.ReceiveParameters<T> args)
        Specified by:
        receive in interface gurux.common.IGXMedia
      • getBytesReceived

        public final long getBytesReceived()
        Received byte count.
        Specified by:
        getBytesReceived in interface gurux.common.IGXMedia
        See Also:
        bytesSent, resetByteCounters()
      • resetByteCounters

        public final void resetByteCounters()
        Resets BytesReceived and BytesSent counters.
        Specified by:
        resetByteCounters in interface gurux.common.IGXMedia
        See Also:
        bytesSent, getBytesReceived()
      • getMaxClientCount

        public final int getMaxClientCount()
        Retrieves maximum count of connected clients.
        Returns:
        Maximum count of connected clients.
      • setMaxClientCount

        public final void setMaxClientCount​(int value)
        Sets maximum count of connected clients.
        Parameters:
        value - Maximum count of connected clients.
      • getSettings

        public final String getSettings()
        Media settings as a XML string.
        Specified by:
        getSettings in interface gurux.common.IGXMedia
      • setSettings

        public final void setSettings​(String value)
        Specified by:
        setSettings in interface gurux.common.IGXMedia
      • copy

        public final void copy​(Object target)
        Specified by:
        copy in interface gurux.common.IGXMedia
      • getName

        public final String getName()
        Specified by:
        getName in interface gurux.common.IGXMedia
      • getMediaType

        public final String getMediaType()
        Specified by:
        getMediaType in interface gurux.common.IGXMedia
      • getSynchronous

        public final Object getSynchronous()
        Specified by:
        getSynchronous in interface gurux.common.IGXMedia
      • getIsSynchronous

        public final boolean getIsSynchronous()
        Specified by:
        getIsSynchronous in interface gurux.common.IGXMedia
      • resetSynchronousBuffer

        public final void resetSynchronousBuffer()
        Specified by:
        resetSynchronousBuffer in interface gurux.common.IGXMedia
      • validate

        public final void validate()
        Specified by:
        validate in interface gurux.common.IGXMedia
      • getEop

        public final Object getEop()
        Specified by:
        getEop in interface gurux.common.IGXMedia
      • setEop

        public final void setEop​(Object value)
        Specified by:
        setEop in interface gurux.common.IGXMedia
      • addListener

        public final void addListener​(gurux.common.IGXMediaListener listener)
        Specified by:
        addListener in interface gurux.common.IGXMedia
      • removeListener

        public final void removeListener​(gurux.common.IGXMediaListener listener)
        Specified by:
        removeListener in interface gurux.common.IGXMedia
      • getReceiveDelay

        public int getReceiveDelay()
        Specified by:
        getReceiveDelay in interface gurux.common.IGXMedia2
      • setReceiveDelay

        public void setReceiveDelay​(int value)
        Specified by:
        setReceiveDelay in interface gurux.common.IGXMedia2
      • getAsyncWaitTime

        public int getAsyncWaitTime()
        Specified by:
        getAsyncWaitTime in interface gurux.common.IGXMedia2
      • setAsyncWaitTime

        public void setAsyncWaitTime​(int value)
        Specified by:
        setAsyncWaitTime in interface gurux.common.IGXMedia2
      • getAsyncWaitHandle

        public Object getAsyncWaitHandle()
        Specified by:
        getAsyncWaitHandle in interface gurux.common.IGXMedia2
      • getLocale

        public Locale getLocale()
        Returns:
        Used locale.
      • setLocale

        public void setLocale​(Locale value)
        Parameters:
        value - Used locale.