Package gurux.net
Class GXNet
- java.lang.Object
-
- gurux.net.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 Summary
Constructors Constructor Description GXNet()Constructor.GXNet(NetworkType networkType, int portNo)Constructor used when server is started.GXNet(NetworkType networkType, String name, int portNo)Client Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaboutBox()Displays the copyright of the control, user license, and version information, in a dialog box.voidaddListener(gurux.common.IGXMediaListener listener)GXNetattach(String address)Attach TCP/IP connection.voidclose()voidcopy(Object target)protected voidfinalize()Destructor.ObjectgetAsyncWaitHandle()intgetAsyncWaitTime()longgetBytesReceived()Received byte count.longgetBytesSent()Sent byte count.intgetConfigurableSettings()intgetConnectionWaitTime()Gets how long (milliseconds) server answer is waited when connection is made.ObjectgetEop()StringgetHostName()Retrieves the name or IP address of the host.booleangetIsSynchronous()LocalegetLocale()intgetMaxClientCount()Retrieves maximum count of connected clients.StringgetMediaType()StringgetName()intgetPort()Retrieves or sets the host or server port number.NetworkTypegetProtocol()Retrieves the used protocol.intgetReceiveDelay()booleangetServer()Is server mode used.StringgetSettings()Media settings as a XML string.ObjectgetSynchronous()gurux.common.enums.TraceLevelgetTrace()booleanisOpen()voidopen()Opens the connection.booleanproperties(JFrame parent)<T> booleanreceive(gurux.common.ReceiveParameters<T> args)voidremoveListener(gurux.common.IGXMediaListener listener)voidresetByteCounters()Resets BytesReceived and BytesSent counters.voidresetSynchronousBuffer()voidsend(Object data, String target)voidsetAsyncWaitTime(int value)voidsetConfigurableSettings(int value)voidsetConnectionWaitTime(int value)Sets how long (milliseconds) server answer is waited when connection is made.voidsetEop(Object value)voidsetHostName(String value)Sets the name or IP address of the host.voidsetLocale(Locale value)voidsetMaxClientCount(int value)Sets maximum count of connected clients.voidsetPort(int value)Retrieves or sets the host or server port number.voidsetProtocol(NetworkType value)Sets the used protocol.voidsetReceiveDelay(int value)voidsetServer(boolean value)Is server mode used.voidsetSettings(String value)voidsetTrace(gurux.common.enums.TraceLevel value)voidvalidate()
-
-
-
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.
-
finalize
protected final void finalize() throws ThrowableDestructor.
-
getTrace
public final gurux.common.enums.TraceLevel getTrace()
- Specified by:
getTracein interfacegurux.common.IGXMedia
-
setTrace
public final void setTrace(gurux.common.enums.TraceLevel value)
- Specified by:
setTracein interfacegurux.common.IGXMedia
-
getConfigurableSettings
public final int getConfigurableSettings()
- Specified by:
getConfigurableSettingsin interfacegurux.common.IGXMedia
-
setConfigurableSettings
public final void setConfigurableSettings(int value)
- Specified by:
setConfigurableSettingsin interfacegurux.common.IGXMedia
-
properties
public final boolean properties(JFrame parent)
- Specified by:
propertiesin interfacegurux.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:
sendin interfacegurux.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 ExceptionOpens the connection. Protocol, Port and HostName must be set, before calling the Open method.
-
close
public final void close()
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfacegurux.common.IGXMedia
-
isOpen
public final boolean isOpen()
- Specified by:
isOpenin interfacegurux.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.
-
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.
-
setPort
public final void setPort(int value)
Retrieves or sets the host or server port number.
-
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:
receivein interfacegurux.common.IGXMedia
-
getBytesSent
public final long getBytesSent()
Sent byte count.- Specified by:
getBytesSentin interfacegurux.common.IGXMedia- See Also:
getBytesReceived(),resetByteCounters()
-
getBytesReceived
public final long getBytesReceived()
Received byte count.- Specified by:
getBytesReceivedin interfacegurux.common.IGXMedia- See Also:
bytesSent,resetByteCounters()
-
resetByteCounters
public final void resetByteCounters()
Resets BytesReceived and BytesSent counters.- Specified by:
resetByteCountersin interfacegurux.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:
getSettingsin interfacegurux.common.IGXMedia
-
setSettings
public final void setSettings(String value)
- Specified by:
setSettingsin interfacegurux.common.IGXMedia
-
copy
public final void copy(Object target)
- Specified by:
copyin interfacegurux.common.IGXMedia
-
getName
public final String getName()
- Specified by:
getNamein interfacegurux.common.IGXMedia
-
getMediaType
public final String getMediaType()
- Specified by:
getMediaTypein interfacegurux.common.IGXMedia
-
getSynchronous
public final Object getSynchronous()
- Specified by:
getSynchronousin interfacegurux.common.IGXMedia
-
getIsSynchronous
public final boolean getIsSynchronous()
- Specified by:
getIsSynchronousin interfacegurux.common.IGXMedia
-
resetSynchronousBuffer
public final void resetSynchronousBuffer()
- Specified by:
resetSynchronousBufferin interfacegurux.common.IGXMedia
-
validate
public final void validate()
- Specified by:
validatein interfacegurux.common.IGXMedia
-
getEop
public final Object getEop()
- Specified by:
getEopin interfacegurux.common.IGXMedia
-
setEop
public final void setEop(Object value)
- Specified by:
setEopin interfacegurux.common.IGXMedia
-
addListener
public final void addListener(gurux.common.IGXMediaListener listener)
- Specified by:
addListenerin interfacegurux.common.IGXMedia
-
removeListener
public final void removeListener(gurux.common.IGXMediaListener listener)
- Specified by:
removeListenerin interfacegurux.common.IGXMedia
-
getReceiveDelay
public int getReceiveDelay()
- Specified by:
getReceiveDelayin interfacegurux.common.IGXMedia2
-
setReceiveDelay
public void setReceiveDelay(int value)
- Specified by:
setReceiveDelayin interfacegurux.common.IGXMedia2
-
getAsyncWaitTime
public int getAsyncWaitTime()
- Specified by:
getAsyncWaitTimein interfacegurux.common.IGXMedia2
-
setAsyncWaitTime
public void setAsyncWaitTime(int value)
- Specified by:
setAsyncWaitTimein interfacegurux.common.IGXMedia2
-
getAsyncWaitHandle
public Object getAsyncWaitHandle()
- Specified by:
getAsyncWaitHandlein interfacegurux.common.IGXMedia2
-
getLocale
public Locale getLocale()
- Returns:
- Used locale.
-
setLocale
public void setLocale(Locale value)
- Parameters:
value- Used locale.
-
-