Module org.snmp4j

Class AbstractSocketEntry<A extends Address>

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>
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 Details

  • Constructor Details

    • 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 Details

    • addRegistration

      public void addRegistration(Selector selector, int opKey) throws ClosedChannelException
      Adds a registration of a selection key to the specified Selector.
      Parameters:
      selector - the Selector 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 specified Selector.
      Parameters:
      selector - the Selector 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.
    • toString

      public abstract String toString()
      Overrides:
      toString in class Object
    • 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.