Interface TcpConnection
- All Superinterfaces:
Runnable
- All Known Subinterfaces:
TcpConnectionInterceptor
- All Known Implementing Classes:
TcpConnectionInterceptorSupport,TcpConnectionSupport,TcpNetConnection,TcpNioConnection,TcpNioSSLConnection
An abstraction over
Socket and SocketChannel
that sends Message objects by serializing the payload and streaming it to the
destination. Requires a TcpListener to receive incoming messages.- Since:
- 2.0
- Author:
- Gary Russell
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the connection.Deserializer<?> Uses the deserializer to obtain the message payload from the connection's input stream.intgetPort()Serializer<?> Provides getters forSocketproperties.longbooleanisOpen()booleanisServer()voidConverts and sends the message.default voidSet the connection's input stream to end of stream.default voidDisable the socket's output stream.
-
Method Details
-
close
void close()Closes the connection. -
isOpen
boolean isOpen()- Returns:
- true if the connection is open.
-
send
-
getPayload
-
getHostName
String getHostName()- Returns:
- the host name
-
getHostAddress
String getHostAddress()- Returns:
- the host address
-
getPort
int getPort()- Returns:
- the port
-
getConnectionId
String getConnectionId()- Returns:
- a string uniquely representing a connection.
-
isServer
boolean isServer()- Returns:
- True if connection is used once.
-
getDeserializer
Deserializer<?> getDeserializer()- Returns:
- the deserializer
-
getSerializer
Serializer<?> getSerializer()- Returns:
- the serializer
-
getListener
- Returns:
- this connection's listener
-
incrementAndGetConnectionSequence
long incrementAndGetConnectionSequence()- Returns:
- the next sequence number for a message received on this socket
-
getDeserializerStateKey
- Returns:
- a key that can be used to reference state in a
Deserializerthat maintains state for this connection. Currently, this would be the InputStream associated with the connection, but the object should be treated as opaque and ONLY used as a key.
-
getSslSession
- Returns:
- the
SSLSessionassociated with this connection, if SSL is in use, null otherwise. - Since:
- 4.2
-
getSocketInfo
SocketInfo getSocketInfo()Provides getters forSocketproperties.- Returns:
- the socketInfo - may be null, for example in interceptors; interceptors should override and delegate to the actual TcpConnection.
- Since:
- 4.3
-
shutdownInput
Set the connection's input stream to end of stream.- Throws:
IOException- an IO Exception.- Since:
- 5.2
-
shutdownOutput
Disable the socket's output stream.- Throws:
IOException- an IO Exception- Since:
- 5.2
-