org.opcfoundation.ua.transport.tcp.nio
Class OpcTcpServer

java.lang.Object
  extended by org.opcfoundation.ua.utils.AbstractState<CloseableObjectState,ServiceResultException>
      extended by org.opcfoundation.ua.transport.tcp.nio.OpcTcpServer
All Implemented Interfaces:
CloseableObject, ConnectionMonitor, EndpointServer, IStatefulObject<CloseableObjectState,ServiceResultException>

public class OpcTcpServer
extends AbstractState<CloseableObjectState,ServiceResultException>
implements EndpointServer

EndpointOpcTcp hosts an endpoint for opc.tcp socket. Endpoint discovery is provided if endpoint url is unknown.

See Also:
for creating executor instances

Nested Class Summary
 class OpcTcpServer.OpcTcpEndpointHandle
           
 class OpcTcpServer.SocketHandle
           
 
Nested classes/interfaces inherited from interface org.opcfoundation.ua.transport.EndpointServer
EndpointServer.EndpointHandle
 
Nested classes/interfaces inherited from interface org.opcfoundation.ua.transport.ConnectionMonitor
ConnectionMonitor.ConnectListener
 
Field Summary
 EndpointBinding discoveryEndpointBinding
           
 Server discoveryServer
          Service server used when client connects with "" url for endpoint discovery
 
Fields inherited from interface org.opcfoundation.ua.transport.EndpointServer
discoveryEndpoint
 
Constructor Summary
OpcTcpServer(Application application)
          Constructor for OpcTcpServer.
 
Method Summary
 void addConnectionListener(ConnectionMonitor.ConnectListener l)
          addConnectionListener.
 EndpointServer.EndpointHandle bind(SocketAddress socketAddress, EndpointBinding endpointBinding)
          Bind an endpoint to a handle.
 OpcTcpServer close()
          Close the object.
 void disconnectAll()
          Disconnect all existing connections.
 SocketAddress getBoundAddress()
          getBoundAddress.
 List<SocketAddress> getBoundSocketAddresses()
          getBoundSocketAddresses.
 void getConnections(Collection<ServerConnection> result)
          getConnections.
 EncoderContext getEncoderContext()
          getEncoderContext.
 EndpointBindingCollection getEndpointBindings()
          Get a collection that contains related endpoints bindings.
 int getReceiveBufferSize()
          Getter for the field receiveBufferSize.
 void removeConnectionListener(ConnectionMonitor.ConnectListener l)
          removeConnectionListener.
 void setReceiveBufferSize(int receiveBufferSize)
          Define the receiveBufferSize to use for the connection socket of the server.
 OpcTcpServer.SocketHandle[] socketHandleSnapshot()
          socketHandleSnapshot.
 String toString()
          
 
Methods inherited from class org.opcfoundation.ua.utils.AbstractState
addStateListener, addStateNotifiable, assertNoError, attemptSetState, clearError, getError, getState, hasError, isStateTransitionAllowed, onListenerException, onStateTransition, removeStateListener, removeStateNotifiable, setError, setState, setState, waitForState, waitForState, waitForStateUninterruptibly
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.opcfoundation.ua.utils.IStatefulObject
addStateListener, addStateNotifiable, getError, getState, removeStateListener, removeStateNotifiable, waitForState, waitForState, waitForStateUninterruptibly
 

Field Detail

discoveryServer

public Server discoveryServer
Service server used when client connects with "" url for endpoint discovery


discoveryEndpointBinding

public EndpointBinding discoveryEndpointBinding
Constructor Detail

OpcTcpServer

public OpcTcpServer(Application application)
             throws ServiceResultException

Constructor for OpcTcpServer.

Parameters:
application - a Application object.
Throws:
ServiceResultException - if any.
Method Detail

getEncoderContext

public EncoderContext getEncoderContext()

getEncoderContext.

Specified by:
getEncoderContext in interface EndpointServer
Returns:
a EncoderContext object.

getReceiveBufferSize

public int getReceiveBufferSize()

Getter for the field receiveBufferSize.

Returns:
the receiveBufferSize to use for the connection socket of the server.

setReceiveBufferSize

public void setReceiveBufferSize(int receiveBufferSize)
                          throws ServiceResultException
Define the receiveBufferSize to use for the connection socket of the server.

Default value: 0, which omits the parameter and the default value for the socket (depending on the operating system) is used.

Parameters:
receiveBufferSize - the new size in bytes
Throws:
ServiceResultException - if any.
See Also:
"http://fasterdata.es.net/host-tuning/background/"

bind

public EndpointServer.EndpointHandle bind(SocketAddress socketAddress,
                                          EndpointBinding endpointBinding)
                                   throws ServiceResultException
Bind an endpoint to a handle.

Specified by:
bind in interface EndpointServer
Parameters:
socketAddress - a SocketAddress object.
endpointBinding - a EndpointBinding object.
Returns:
a EndpointServer.EndpointHandle object.
Throws:
ServiceResultException - if any.

getBoundSocketAddresses

public List<SocketAddress> getBoundSocketAddresses()

getBoundSocketAddresses.

Specified by:
getBoundSocketAddresses in interface EndpointServer
Returns:
a List object.

getBoundAddress

public SocketAddress getBoundAddress()

getBoundAddress.

Returns:
a SocketAddress object.

disconnectAll

public void disconnectAll()
Disconnect all existing connections.


close

public OpcTcpServer close()
Close the object. This method is async, invocation makes the object go into closing state. Closes server socket. Does not disconnect existing connections.

Specified by:
close in interface CloseableObject
Returns:
a CloseableObject object.

addConnectionListener

public void addConnectionListener(ConnectionMonitor.ConnectListener l)

addConnectionListener.

Specified by:
addConnectionListener in interface ConnectionMonitor
Parameters:
l - a ConnectionMonitor.ConnectListener object.

getConnections

public void getConnections(Collection<ServerConnection> result)

getConnections.

Specified by:
getConnections in interface ConnectionMonitor
Parameters:
result - a Collection object.

removeConnectionListener

public void removeConnectionListener(ConnectionMonitor.ConnectListener l)

removeConnectionListener.

Specified by:
removeConnectionListener in interface ConnectionMonitor
Parameters:
l - a ConnectionMonitor.ConnectListener object.

getEndpointBindings

public EndpointBindingCollection getEndpointBindings()
Get a collection that contains related endpoints bindings.

Specified by:
getEndpointBindings in interface EndpointServer
Returns:
endpoint collection

toString

public String toString()

Overrides:
toString in class Object

socketHandleSnapshot

public OpcTcpServer.SocketHandle[] socketHandleSnapshot()

socketHandleSnapshot.

Returns:
an array of OpcTcpServer.SocketHandle objects.


Copyright © 2018. All rights reserved.