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
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAbstractSocketEntry(A address, SocketChannel socketChannel) Creates a socket entry with address and socket channel. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddMessage(byte[] message) Add a message to be sent to the socket entries internal queue.voidaddRegistration(Selector selector, int opKey) Adds a registration of a selection key to the specifiedSelector.abstract voidClose the (TLS) session associated with the socket entry.List<byte[]> Gets the messages to be sent over this socket entry.abstract ObjectGets the unique identifier of the associated (TLS) session.Gets the socket channel associated with this socket entry.booleanCheck if there are messages to be sent.voidinsertMessages(List<byte[]> messages) Insert the given messages before already queued messages to the to-be-sent queue.booleanisRegistered(int opKey) Check if the given operation(s) is registerdintIncrease the busy looping counter and return it.byte[]Gets the next message from the send queue.voidremoveRegistration(Selector selector, int opKey) Removes a registration of a selection key from the specifiedSelector.voidResets the busy looping counter to 0.abstract StringtoString()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- theSelectorto 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- theSelectorto 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:
trueif the given operation key(s) is/are registered,falseotherwise.
-
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
nullif there is no message to be sent left.
-
hasMessage
public boolean hasMessage()Check if there are messages to be sent.- Returns:
trueif 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.
-