|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.opcfoundation.ua.transport.tcp.io.TcpConnection
public class TcpConnection
This class implements OPC UA Secure Conversation (UASC) for client to server communication.
OPC UA TCP is a simple TCP based protocol that establishes a full duplex channel between a client and server. This protocol has two key features that differentiate it from HTTP. First, this protocol allows responses to be returned in any order. Second, this protocol allows responses to be returned on a different socket if communication failures causes temporary socket interruption. The OPC UA TCP protocol is designed to work with the SecureChannel implemented by a layer higher in the stack. For this reason, the OPC UA TCP protocol defines its interactions with the SecureChannel in addition to the wire protocol.
Features included in this class:
o Establishing connection, Handshake
o Sync and Async encryption Features excluded in this class:
o Reconnect (See SecureChannel)
o Token Renewal (See SecureChannel)
TcpConnection is instantiated and managed by SecureChannel which also
handles Reconnection and token renewal.
OpenSecureChannelRequest and OpenSecureChannelResponse is
ciphered with asymmetric encryption using the certificates set in initialize.
Asymmetric encryption is omited if server certificate is null. (This is not
allowed in Part 4, but is in Part 6). DiscoveryClient uses unencrypted
connection.
TcpConnection captures security tokens from OpenSecureChannel conversation
and uses them for symmetric messaging. The oldest non-expired token is used.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface org.opcfoundation.ua.transport.tcp.io.IConnection |
|---|
IConnection.IMessageListener |
| Constructor Summary | |
|---|---|
TcpConnection()
|
|
| Method Summary | |
|---|---|
void |
addConnectionListener(IConnectionListener listener)
Add response listener |
void |
addMessageListener(IConnection.IMessageListener listener)
Add input stream message listener. |
void |
close()
Close the socket connection. |
void |
dispose()
Optional dispose closes connection and clears all variables |
EndpointConfiguration |
getEndpointConfiguration()
Getter for the field endpointConfiguration. |
EndpointDescription |
getEndpointDescription()
Getter for the field endpointDescription. |
int |
getHandshakeTimeout()
Getter for the field handshakeTimeout. |
EncoderContext |
getMessageContext()
getMessageContext. |
int |
getProtocolVersion()
Get the protocol version agreen in the hand-shake |
static int |
getReceiveBufferSize()
Getter for the field receiveBufferSize. |
static int |
getSendBufferSize()
Getter for the field sendBufferSize. |
protected Socket |
getSocket()
Getter for the field socket. |
SocketAddress |
getSocketAddress()
Get the initialized socket address |
void |
initialize(InetSocketAddress addr,
TransportChannelSettings settings,
EncoderContext ctx)
Set connection configuration parameters. |
void |
initialize(String url,
TransportChannelSettings settings,
EncoderContext ctx)
|
void |
initialize(TransportChannelSettings settings,
EncoderContext ctx)
initialize. |
void |
open()
open. |
void |
reconnect()
reconnect. |
void |
removeConnectionListener(IConnectionListener listener)
Add response listener |
void |
removeMessageListener(IConnection.IMessageListener listener)
removeMessageListener. |
void |
sendRequest(ServiceRequest request,
int secureChannelId,
int requestId)
Send request to the connection. |
void |
setHandshakeTimeout(int handshakeTimeout)
Setter for the field handshakeTimeout. |
static void |
setReceiveBufferSize(int receiveBufferSize)
Define the receiveBufferSize to use for the connection socket. |
static void |
setSendBufferSize(int sendBufferSize)
Define the sendBufferSize to use for the connection socket. |
protected void |
setSocket(Socket socket)
Setter for the field socket. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public TcpConnection()
| Method Detail |
|---|
protected void setSocket(Socket socket)
Setter for the field socket.
socket - the socket to setpublic static int getReceiveBufferSize()
Getter for the field receiveBufferSize.
public static void setReceiveBufferSize(int receiveBufferSize)
Default value: 0, which omits the parameter and the default value for the socket (depending on the operating system) is used.
receiveBufferSize - the new size in bytespublic static int getSendBufferSize()
Getter for the field sendBufferSize.
public static void setSendBufferSize(int sendBufferSize)
Default value: 0, which omits the parameter and the default value for the socket (depending on the operating system) is used.
sendBufferSize - the new size in bytes
public void initialize(TransportChannelSettings settings,
EncoderContext ctx)
throws ServiceResultException
initialize.
settings - a TransportChannelSettings object.ctx - a EncoderContext object.
ServiceResultException - if any.
public void initialize(String url,
TransportChannelSettings settings,
EncoderContext ctx)
throws ServiceResultException
ServiceResultException
public void initialize(InetSocketAddress addr,
TransportChannelSettings settings,
EncoderContext ctx)
throws ServiceResultException
initialize in interface IConnectionaddr - a InetSocketAddress object.settings - a TransportChannelSettings object.ctx - a EncoderContext object.
ServiceResultException - if any.
public void open()
throws ServiceResultException
open.
open in interface IConnectionServiceResultException - if any.public void close()
close in interface IConnectionprotected Socket getSocket()
Getter for the field socket.
Socket object.
public void reconnect()
throws ServiceResultException
reconnect.
reconnect in interface IConnectionServiceResultException - if any.public EndpointConfiguration getEndpointConfiguration()
Getter for the field endpointConfiguration.
EndpointConfiguration object.public EndpointDescription getEndpointDescription()
Getter for the field endpointDescription.
EndpointDescription object.public EncoderContext getMessageContext()
getMessageContext.
EncoderContext object.public void dispose()
dispose in interface IConnection
public void sendRequest(ServiceRequest request,
int secureChannelId,
int requestId)
throws ServiceResultException
Thread.interrupt().
sendRequest in interface IConnectionsecureChannelId - a int.
ServiceResultException - varies. Bad_NotConnected if connection is not establishedpublic int getHandshakeTimeout()
Getter for the field handshakeTimeout.
public void setHandshakeTimeout(int handshakeTimeout)
Setter for the field handshakeTimeout.
handshakeTimeout - a int.public void addMessageListener(IConnection.IMessageListener listener)
addMessageListener in interface IConnectionlistener - message listenerpublic void removeMessageListener(IConnection.IMessageListener listener)
removeMessageListener.
removeMessageListener in interface IConnectionlistener - a IMessageListener object.public void addConnectionListener(IConnectionListener listener)
addConnectionListener in interface IConnectionlistener - a IConnectionListener object.public void removeConnectionListener(IConnectionListener listener)
removeConnectionListener in interface IConnectionlistener - a IConnectionListener object.public int getProtocolVersion()
public SocketAddress getSocketAddress()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||