java.lang.Object
org.snmp4j.transport.AbstractServerSocket<A>
org.snmp4j.transport.AbstractSocketEntry<A>
- Type Parameters:
A
- the address type.
- Direct Known Subclasses:
DefaultTcpTransportMapping.SocketEntry
The
AbstractSocketEntry
extends the AbstractServerSocket
and implements a generic
Address
to SocketChannel
mapping to be used by TransportMapping
.- Version:
- 3.7.0
- Author:
- Frank Fock
-
Field Summary
-
Constructor Summary
ConstructorDescriptionAbstractSocketEntry
(A address, SocketChannel socketChannel) Creates a socket entry with address and socket channel. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addMessage
(byte[] message) Add a message to be sent to the socket entries internal queue.void
addRegistration
(Selector selector, int opKey) Adds a registration of a selection key to the specifiedSelector
.abstract void
Close the (TLS) session associated with the socket entry.List
<byte[]> Gets the messages to be sent over this socket entry.abstract Object
Gets the unique identifier of the associated (TLS) session.Gets the socket channel associated with this socket entry.boolean
Check if there are messages to be sent.void
insertMessages
(List<byte[]> messages) Insert the given messages before already queued messages to the to-be-sent queue.boolean
isRegistered
(int opKey) Check if the given operation(s) is registerdint
Increase the busy looping counter and return it.byte[]
Gets the next message from the send queue.void
removeRegistration
(Selector selector, int opKey) Removes a registration of a selection key from the specifiedSelector
.void
Resets the busy looping counter to 0.abstract String
toString()
Methods inherited from class org.snmp4j.transport.AbstractServerSocket
getLastUse, getPeerAddress, getSocketTimeout, isHandshakeFinished, setHandshakeFinished, setSocketTimeout, used
-
Field Details
-
socketChannel
-
-
Constructor Details
-
AbstractSocketEntry
Creates a socket entry with address and socket channel.- Parameters:
address
- the remote address associated with this socket entry.socketChannel
- the socket channel holding the connection to the above remote address.
-
-
Method Details
-
addRegistration
Adds a registration of a selection key to the specifiedSelector
.- Parameters:
selector
- theSelector
to be changed.opKey
- the operation(s) to be registered.- Throws:
ClosedChannelException
- if the socket channel associated with the given selector is already closed.
-
removeRegistration
Removes a registration of a selection key from the specifiedSelector
.- Parameters:
selector
- theSelector
to be changed.opKey
- the operation(s) to be unregistered.- Throws:
ClosedChannelException
- if the socket channel associated with the given selector is already closed.
-
isRegistered
public boolean isRegistered(int opKey) Check if the given operation(s) is registerd- Parameters:
opKey
- the operation(s) to check.- Returns:
true
if the given operation key(s) is/are registered,false
otherwise.
-
getSocketChannel
Gets the socket channel associated with this socket entry.- Returns:
- the socket channel.
-
getMessages
Gets the messages to be sent over this socket entry.- Returns:
- a list of byte arrays. Each byte array represents a message.
-
addMessage
public void addMessage(byte[] message) Add a message to be sent to the socket entries internal queue.- Parameters:
message
- a new message to be sent.
-
insertMessages
Insert the given messages before already queued messages to the to-be-sent queue.- Parameters:
messages
- a new message to be sent.
-
nextMessage
public byte[] nextMessage()Gets the next message from the send queue.- Returns:
- the next message or
null
if there is no message to be sent left.
-
hasMessage
public boolean hasMessage()Check if there are messages to be sent.- Returns:
true
if there is at least one message to be sent queued.
-
nextBusyLoop
public int nextBusyLoop()Increase the busy looping counter and return it.- Returns:
- the current busy looping counter.
-
resetBusyLoops
public void resetBusyLoops()Resets the busy looping counter to 0. -
toString
-
closeSession
public abstract void closeSession()Close the (TLS) session associated with the socket entry. -
getSessionID
Gets the unique identifier of the associated (TLS) session.- Returns:
- a session identifier.
-