Package 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
Modifier and TypeMethodDescriptionvoidcancel(PDU request, ResponseListener listener) Cancels an asynchronous request.voidclose()Closes the session and frees any allocated resources, i.e.Sends aPDUto the given target and returns the received responsePDU.voidsend(PDU pdu, Target target, Object userHandle, ResponseListener listener) Asynchronously sends aPDUto the given target.send(PDU pdu, Target target, TransportMapping transport) Sends aPDUto the given target and returns the received responsePDUencapsulated in aResponseEventobject that also includes: the transport address of the response sending peer, theTargetinformation of the target, the requestPDU, the responsePDU(if any).voidsend(PDU pdu, Target target, TransportMapping transport, Object userHandle, ResponseListener listener) Asynchronously sends aPDUto the given target. 
- 
Method Details
- 
close
Closes the session and frees any allocated resources, i.e. sockets. After aSessionhas been closed it must be used.- Throws:
 IOException- if the session could not free all resources.
 - 
send
Sends aPDUto the given target and returns the received responsePDU.- Parameters:
 pdu- thePDUto send.target- theTargetinstance that specifies how and where to send the PDU.- Returns:
 - the received response encapsulated in a 
ResponseEventinstance. To obtain the received responsePDUcallResponseEvent.getResponse(). If the request timed out, that method will returnnull. If the sentpduis an unconfirmed PDU (notification, response, or report), thennullwill be returned. - Throws:
 IOException- if the message could not be send.
 - 
send
Asynchronously sends aPDUto the given target. The response is then returned by calling the suppliedResponseListenerinstance.- Parameters:
 pdu- the PDU instance to send.target- the Target instance representing the target SNMP engine where to send thepdu.userHandle- an user defined handle that is returned when the request is returned via thelistenerobject.listener- aResponseListenerinstance that is called whenpduis a confirmed PDU and the request is either answered or timed out.- Throws:
 IOException- if the message could not be send.
 - 
send
Sends aPDUto the given target and returns the received responsePDUencapsulated in aResponseEventobject that also includes:- the transport address of the response sending peer,
 - the 
Targetinformation of the target, - the request 
PDU, - the response 
PDU(if any). 
- Parameters:
 pdu- the PDU instance to send.target- the Target instance representing the target SNMP engine where to send thepdu.transport- specifies theTransportMappingto be used when sending the PDU. Iftransportisnull, the associated message dispatcher will try to determine the transport mapping by thetarget's address.- Returns:
 - the received response encapsulated in a 
ResponseEventinstance. To obtain the received responsePDUcallResponseEvent.getResponse(). If the request timed out, that method will returnnull. If the sentpduis an unconfirmed PDU (notification, response, or report), thennullwill be returned. - Throws:
 IOException- if the message could not be send.
 - 
send
void send(PDU pdu, Target target, TransportMapping transport, Object userHandle, ResponseListener listener) throws IOException Asynchronously sends aPDUto the given target. The response is then returned by calling the suppliedResponseListenerinstance.- Parameters:
 pdu- the PDU instance to send.target- the Target instance representing the target SNMP engine where to send thepdu.transport- specifies theTransportMappingto be used when sending the PDU. Iftransportisnull, the associated message dispatcher will try to determine the transport mapping by thetarget's address.userHandle- an user defined handle that is returned when the request is returned via thelistenerobject.listener- aResponseListenerinstance that is called whenpduis a confirmed PDU and the request is either answered or timed out.- Throws:
 IOException- if the message could not be send.
 - 
cancel
Cancels an asynchronous request. Any asynchronous request must be canceled when the supplied response listener is being called, even if theResponseEventindicates an error.- Parameters:
 request- a request PDU as sent viasend(PDU pdu, Target target, Object userHandle, ResponseListener listener)or any .listener- a ResponseListener instance.
 
 -