Module org.snmp4j
Package org.snmp4j.transport
Interface ConnectionOrientedTransportMapping<A extends Address>
-
- All Superinterfaces:
java.lang.AutoCloseable
,java.io.Closeable
,TransportMapping<A>
- All Known Implementing Classes:
DefaultTcpTransportMapping
,DTLSTM
,TcpTransportMapping
,TLSTM
public interface ConnectionOrientedTransportMapping<A extends Address> extends TransportMapping<A>
Transport mappings for connection oriented transport protocols have to implement this interface.- Since:
- 1.7
- Version:
- 3.5.0
- Author:
- Frank Fock
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addTransportStateListener(TransportStateListener l)
Adds a transport state listener that is to be informed about connection state changes.boolean
close(A remoteAddress)
Closes the connection to the given remote address (socket).long
getConnectionTimeout()
Gets the connection timeout in millisecondsMessageLengthDecoder
getMessageLengthDecoder()
Returns theMessageLengthDecoder
used by this transport mapping.CommonTimer
getSocketCleaner()
Gets theCommonTimer
that controls socket cleanup operations.boolean
isServerEnabled()
Checks whether a server for incoming requests is enabled.void
removeTransportStateListener(TransportStateListener l)
Removes the supplied transport state listener.boolean
resumeAddress(A addressToResumeSending)
Resume sending of messages to the specified address.void
setConnectionTimeout(long connectionTimeout)
Sets the connection timeout.void
setMessageLengthDecoder(MessageLengthDecoder messageLengthDecoder)
Sets theMessageLengthDecoder
that decodes the total message length from the header of a message.void
setServerEnabled(boolean serverEnabled)
Sets whether a server for incoming requests should be created when the transport is set into listen state.void
suspendAddress(A addressToSuspendSending)
Suspend sending of messages to the specified address, regardless if a connection is already established or not.-
Methods inherited from interface org.snmp4j.TransportMapping
addTransportListener, close, getListenAddress, getMaxInboundMessageSize, getSupportedAddressClass, getSupportedAddressClasses, getSupportedTransportType, isAddressSupported, isAddressSupported, isListening, listen, removeTransportListener, sendMessage
-
-
-
-
Method Detail
-
resumeAddress
boolean resumeAddress(A addressToResumeSending)
Resume sending of messages to the specified address.- Parameters:
addressToResumeSending
- an arbitrary remote address for which any messages send byTransportMapping.sendMessage(Address, byte[], TransportStateReference, long, int)
should be dropped before sending and reopening a connection to that address.- Returns:
true
if the specified address was previously suspended and is now resumed to allow sending messages,false
otherwise.- Since:
- 3.4.4
-
suspendAddress
void suspendAddress(A addressToSuspendSending)
Suspend sending of messages to the specified address, regardless if a connection is already established or not. To be able to send messages again to the specified address usingTransportMapping.sendMessage(Address, byte[], TransportStateReference, long, int)
, callresumeAddress(A)
.- Parameters:
addressToSuspendSending
- an arbitrary remote address for which any messages send byTransportMapping.sendMessage(Address, byte[], TransportStateReference, long, int)
should be dropped before sending and reopening a connection to that address.- Since:
- 3.4.4
-
isServerEnabled
boolean isServerEnabled()
Checks whether a server for incoming requests is enabled.- Returns:
- boolean
-
getMessageLengthDecoder
MessageLengthDecoder getMessageLengthDecoder()
Returns theMessageLengthDecoder
used by this transport mapping.- Returns:
- a MessageLengthDecoder instance.
-
setServerEnabled
void setServerEnabled(boolean serverEnabled)
Sets whether a server for incoming requests should be created when the transport is set into listen state. Setting this value has no effect until theTransportMapping.listen()
method is called (if the transport is already listening,TransportMapping.close()
has to be called before).- Parameters:
serverEnabled
- iftrue
if the transport will listens for incoming requests afterTransportMapping.listen()
has been called.
-
setMessageLengthDecoder
void setMessageLengthDecoder(MessageLengthDecoder messageLengthDecoder)
Sets theMessageLengthDecoder
that decodes the total message length from the header of a message.- Parameters:
messageLengthDecoder
- a MessageLengthDecoder instance.
-
setConnectionTimeout
void setConnectionTimeout(long connectionTimeout)
Sets the connection timeout. This timeout specifies the time a connection may be idle before it is closed.- Parameters:
connectionTimeout
- the idle timeout in milliseconds. A zero or negative value will disable any timeout and connections opened by this transport mapping will stay opened until they are explicitly closed.
-
addTransportStateListener
void addTransportStateListener(TransportStateListener l)
Adds a transport state listener that is to be informed about connection state changes.- Parameters:
l
- a TransportStateListener.
-
removeTransportStateListener
void removeTransportStateListener(TransportStateListener l)
Removes the supplied transport state listener.- Parameters:
l
- a TransportStateListener.
-
close
boolean close(A remoteAddress) throws java.io.IOException
Closes the connection to the given remote address (socket).- Parameters:
remoteAddress
- the address of the remote socket.- Returns:
true
if the connection could be closed andfalse
if the connection does not exists.- Throws:
java.io.IOException
- if closing the connection with the specified remote address fails.- Since:
- 1.7.1
-
getSocketCleaner
CommonTimer getSocketCleaner()
Gets theCommonTimer
that controls socket cleanup operations.- Returns:
- a socket cleaner timer.
- Since:
- 3.0
-
getConnectionTimeout
long getConnectionTimeout()
Gets the connection timeout in milliseconds- Returns:
- the timeout millis after which an inactive connection can be closed.
- Since:
- 3.0
-
-