- java.lang.Object
-
- org.snmp4j.transport.AbstractServerSocket<A>
-
- org.snmp4j.transport.AbstractSocketEntry<A>
-
- Type Parameters:
A
- the address type.
- Direct Known Subclasses:
DefaultTcpTransportMapping.SocketEntry
public abstract class AbstractSocketEntry<A extends Address> extends AbstractServerSocket<A>
TheAbstractSocketEntry
extends theAbstractServerSocket
and implements a genericAddress
toSocketChannel
mapping to be used byTransportMapping
.- Version:
- 3.7.0
- Author:
- Frank Fock
-
-
Field Summary
Fields Modifier and Type Field Description protected SocketChannel
socketChannel
-
Constructor Summary
Constructors Constructor Description AbstractSocketEntry(A address, SocketChannel socketChannel)
Creates a socket entry with address and socket channel.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
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
closeSession()
Close the (TLS) session associated with the socket entry.List<byte[]>
getMessages()
Gets the messages to be sent over this socket entry.abstract Object
getSessionID()
Gets the unique identifier of the associated (TLS) session.SocketChannel
getSocketChannel()
Gets the socket channel associated with this socket entry.boolean
hasMessage()
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
nextBusyLoop()
Increase the busy looping counter and return it.byte[]
nextMessage()
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
resetBusyLoops()
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 Detail
-
socketChannel
protected SocketChannel socketChannel
-
-
Constructor Detail
-
AbstractSocketEntry
public AbstractSocketEntry(A address, SocketChannel socketChannel)
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 Detail
-
addRegistration
public void addRegistration(Selector selector, int opKey) throws ClosedChannelException
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
public void removeRegistration(Selector selector, int opKey) throws ClosedChannelException
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
public SocketChannel getSocketChannel()
Gets the socket channel associated with this socket entry.- Returns:
- the socket channel.
-
getMessages
public List<byte[]> 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
public void insertMessages(List<byte[]> messages)
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.
-
closeSession
public abstract void closeSession()
Close the (TLS) session associated with the socket entry.
-
getSessionID
public abstract Object getSessionID()
Gets the unique identifier of the associated (TLS) session.- Returns:
- a session identifier.
-
-