org.snmp4j
Interface Session

All Known Implementing Classes:
Snmp

public interface Session

Session defines a common interface for all classes that implement SNMP protocol operations based on SNMP4J.

Version:
1.2
Author:
Frank Fock

Method Summary
 void cancel(PDU request, ResponseListener listener)
          Cancels an asynchronous request.
 void close()
          Closes the session and frees any allocated resources, i.e.
 ResponseEvent send(PDU pdu, Target target)
          Sends a PDU to the given target and returns the received response PDU.
 void send(PDU pdu, Target target, java.lang.Object userHandle, ResponseListener listener)
          Asynchronously sends a PDU to the given target.
 ResponseEvent send(PDU pdu, Target target, TransportMapping transport)
          Sends a PDU to the given target and returns the received response PDU encapsulated in a ResponseEvent object that also includes: the transport address of the response sending peer, the Target information of the target, the request PDU, the response PDU (if any).
 void send(PDU pdu, Target target, TransportMapping transport, java.lang.Object userHandle, ResponseListener listener)
          Asynchronously sends a PDU to the given target.
 

Method Detail

close

void close()
           throws java.io.IOException
Closes the session and frees any allocated resources, i.e. sockets. After a Session has been closed it must be used.

Throws:
java.io.IOException - if the session could not free all resources.

send

ResponseEvent send(PDU pdu,
                   Target target)
                   throws java.io.IOException
Sends a PDU to the given target and returns the received response PDU.

Parameters:
pdu - the PDU to send.
target - the Target instance that specifies how and where to send the PDU.
Returns:
the received response encapsulated in a ResponseEvent instance. To obtain the received response PDU call ResponseEvent.getResponse(). If the request timed out, that method will return null. If the sent pdu is an unconfirmed PDU (notification, response, or report), then null will be returned.
Throws:
java.io.IOException - if the message could not be send.

send

void send(PDU pdu,
          Target target,
          java.lang.Object userHandle,
          ResponseListener listener)
          throws java.io.IOException
Asynchronously sends a PDU to the given target. The response is then returned by calling the supplied ResponseListener instance.

Parameters:
pdu - the PDU instance to send.
target - the Target instance representing the target SNMP engine where to send the pdu.
userHandle - an user defined handle that is returned when the request is returned via the listener object.
listener - a ResponseListener instance that is called when pdu is a confirmed PDU and the request is either answered or timed out.
Throws:
java.io.IOException - if the message could not be send.

send

ResponseEvent send(PDU pdu,
                   Target target,
                   TransportMapping transport)
                   throws java.io.IOException
Sends a PDU to the given target and returns the received response PDU encapsulated in a ResponseEvent object that also includes:

Parameters:
pdu - the PDU instance to send.
target - the Target instance representing the target SNMP engine where to send the pdu.
transport - specifies the TransportMapping to be used when sending the PDU. If transport is null, the associated message dispatcher will try to determine the transport mapping by the target's address.
Returns:
the received response encapsulated in a ResponseEvent instance. To obtain the received response PDU call ResponseEvent.getResponse(). If the request timed out, that method will return null. If the sent pdu is an unconfirmed PDU (notification, response, or report), then null will be returned.
Throws:
java.io.IOException - if the message could not be send.

send

void send(PDU pdu,
          Target target,
          TransportMapping transport,
          java.lang.Object userHandle,
          ResponseListener listener)
          throws java.io.IOException
Asynchronously sends a PDU to the given target. The response is then returned by calling the supplied ResponseListener instance.

Parameters:
pdu - the PDU instance to send.
target - the Target instance representing the target SNMP engine where to send the pdu.
transport - specifies the TransportMapping to be used when sending the PDU. If transport is null, the associated message dispatcher will try to determine the transport mapping by the target's address.
userHandle - an user defined handle that is returned when the request is returned via the listener object.
listener - a ResponseListener instance that is called when pdu is a confirmed PDU and the request is either answered or timed out.
Throws:
java.io.IOException - if the message could not be send.

cancel

void cancel(PDU request,
            ResponseListener listener)
Cancels an asynchronous request. Any asynchronous request must be canceled when the supplied response listener is being called, even if the ResponseEvent indicates an error.

Parameters:
request - a request PDU as sent via send(PDU pdu, Target target, Object userHandle, ResponseListener listener) or any .
listener - a ResponseListener instance.

Copyright 2005-2010 Frank Fock (SNMP4J.org)

Copyright © 2011 SNMP4J.org. All Rights Reserved.