Class ListeningContextPool
- All Implemented Interfaces:
 ListeningContextFace
- Since:
 - 4_14
 - Version:
 - $Revision: 3.7 $ $Date: 2009/03/05 13:27:41 $
 - Author:
 - Birgit Arkesteijn
 - See Also:
 
- 
Field Summary
Fields inherited from interface uk.co.westhawk.snmp.stack.ListeningContextFace
DEFAULT_TRAP_PORT - 
Constructor Summary
ConstructorsConstructorDescriptionListeningContextPool(int port) Constructor, using the Standard socket type.ListeningContextPool(int port, String bindAddress) Constructor, using the Standard socket type.ListeningContextPool(int port, String bindAddress, String typeSocket) Constructor. - 
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the specified PDU listener to receive the undecoded PDUs.voidAdds the specified PDU listener to receive the undecoded PDUs when it was not handled (i.e. not consumed) by any of the PDU listeners in addRawPduListener().voiddestroy()Destroys the current context.voidDestroys all the contexts in the pool and empties the pool.voiddumpContexts(String title) Dumps the pool of contexts.Returns the local address the server will bind to When the address is null, the socket accepts connections on any/all local addresses.Returns the hash key.intReturns the maximum number of bytes this context will read from the socket.intgetPort()Returns the port number.Returns the type of socket.voidRemoves the specified PDU listener.voidRemoves the specified PDU listener from all the contexts in the pool.voidRemoves the specified unhandled PDU listener.voidsetMaxRecvSize(int no) Sets the maximum number of bytes this context will read from the socket.toString()Returns a string representation of the object. 
- 
Constructor Details
- 
ListeningContextPool
public ListeningContextPool(int port) Constructor, using the Standard socket type.- Parameters:
 port- The local port where packets are received- See Also:
 
 - 
ListeningContextPool
Constructor, using the Standard socket type. If bindAddress is null, it will accept connections on any/all local addresses. If you want to listen to- IPv4 only interfaces, use address "0.0.0.0"
 - IPv6 only interfaces, use address "::"
 
- Parameters:
 port- The local port where packets are receivedbindAddress- The local address the server will bind to- See Also:
 
 - 
ListeningContextPool
Constructor. If bindAddress is null, it will accept connections on any/all local addresses. If you want to listen to- IPv4 only interfaces, use address "0.0.0.0"
 - IPv6 only interfaces, use address "::"
 
Note, the TCP_SOCKET does not provide functionality to send a response back. Listening on such a socket is only useful when listening for traps.
- Parameters:
 port- The local port where packets are receivedbindAddress- The local address the server will bind totypeSocket- The type of socket to use.- See Also:
 
 
 - 
 - 
Method Details
- 
getPort
public int getPort()Description copied from interface:ListeningContextFaceReturns the port number.- Specified by:
 getPortin interfaceListeningContextFace- Returns:
 - The port no
 
 - 
getBindAddress
Description copied from interface:ListeningContextFaceReturns the local address the server will bind to When the address is null, the socket accepts connections on any/all local addresses.- Specified by:
 getBindAddressin interfaceListeningContextFace- Returns:
 - The bind address
 
 - 
getTypeSocket
Description copied from interface:ListeningContextFaceReturns the type of socket.- Specified by:
 getTypeSocketin interfaceListeningContextFace- Returns:
 - The type of socket
 - See Also:
 
 - 
getMaxRecvSize
public int getMaxRecvSize()Description copied from interface:ListeningContextFaceReturns the maximum number of bytes this context will read from the socket. By default this will be set toMSS(i.e. 1300).- Specified by:
 getMaxRecvSizein interfaceListeningContextFace- Returns:
 - The number
 - See Also:
 
 - 
setMaxRecvSize
public void setMaxRecvSize(int no) Sets the maximum number of bytes this context will read from the socket. By default this will be set toMSS(i.e. 1300). Only the current context will be affected, not to all the contexts in the pool.- Specified by:
 setMaxRecvSizein interfaceListeningContextFace- Parameters:
 no- The new size- See Also:
 
 - 
destroy
public void destroy()Destroys the current context.Note that by calling this method the whole stack will stop listening for packets on the port this context was listening on! The listeners added via the SnmpContext classes are affected as well.
- Specified by:
 destroyin interfaceListeningContextFace- See Also:
 
 - 
destroyPool
public void destroyPool()Destroys all the contexts in the pool and empties the pool.Note that by calling this method the whole stack will stop listening for any packets! The listeners added via the SnmpContext classes are affected as well.
- See Also:
 
 - 
dumpContexts
Dumps the pool of contexts. This is for debug purposes.- Parameters:
 title- The title of the dump
 - 
getHashKey
Returns the hash key. This key is built out of all properties. It serves as key for the pool of contexts.- Returns:
 - The hash key
 
 - 
addRawPduListener
Description copied from interface:ListeningContextFaceAdds the specified PDU listener to receive the undecoded PDUs. When a PDU is received the PDU received event is fired to all listeners, until one of them consumes it.All the SnmpContext objects use this method to listen for PDUs. When a SnmpContext object decodes the PDU succesfully, it will consume it.
Only when a listener is added will this context create a listening socket.
- Specified by:
 addRawPduListenerin interfaceListeningContextFace- Parameters:
 l- The listener object- Throws:
 IOException- Thrown when creating a listening socket fails- See Also:
 - 
RawPduReceivedSupport.fireRawPduReceived(int, java.lang.String, int, byte[])AbstractSnmpContext.addTrapListener(uk.co.westhawk.snmp.event.TrapListener)AbstractSnmpContext.addRequestPduListener(uk.co.westhawk.snmp.event.RequestPduListener)ListeningContextFace.addUnhandledRawPduListener(RawPduListener)
 
 - 
removeRawPduListener
Description copied from interface:ListeningContextFaceRemoves the specified PDU listener. When there are no more listeners, calls destroy().- Specified by:
 removeRawPduListenerin interfaceListeningContextFace- Parameters:
 l- The listener object
 - 
removeRawPduListenerFromPool
Removes the specified PDU listener from all the contexts in the pool. - 
addUnhandledRawPduListener
Description copied from interface:ListeningContextFaceAdds the specified PDU listener to receive the undecoded PDUs when it was not handled (i.e. not consumed) by any of the PDU listeners in addRawPduListener().Only when a listener is added will this context create a listening socket.
- Specified by:
 addUnhandledRawPduListenerin interfaceListeningContextFace- Parameters:
 l- The listener object- Throws:
 IOException- Thrown when creating a listening socket fails- See Also:
 
 - 
removeUnhandledRawPduListener
Description copied from interface:ListeningContextFaceRemoves the specified unhandled PDU listener. When there are no more listeners, calls destroy().- Specified by:
 removeUnhandledRawPduListenerin interfaceListeningContextFace- Parameters:
 l- The listener object
 - 
toString
Returns a string representation of the object. 
 -