- java.lang.Object
-
- org.snmp4j.transport.AbstractTransportMapping<UdpAddress>
-
- org.snmp4j.transport.UdpTransportMapping
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,TransportMapping<UdpAddress>
- Direct Known Subclasses:
DefaultUdpTransportMapping
public abstract class UdpTransportMapping extends AbstractTransportMapping<UdpAddress>
TheUdpTransportMappingis the abstract base class for UDP transport mappings.- Version:
- 3.0
- Author:
- Frank Fock
-
-
Field Summary
Fields Modifier and Type Field Description protected UdpAddressudpAddress-
Fields inherited from class org.snmp4j.transport.AbstractTransportMapping
asyncMsgProcessingSupported, maxInboundMessageSize, transportListener
-
-
Constructor Summary
Constructors Constructor Description UdpTransportMapping(UdpAddress udpAddress)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract voidclose()Closes the transport an releases all bound resources synchronously.UdpAddressgetAddress()Returns the transport address that is configured for this transport mapping for sending and receiving messages.UdpAddressgetListenAddress()Returns the address that represents the actual incoming address this transport mapping uses to listen for incoming packets.java.lang.Class<? extends Address>getSupportedAddressClass()Gets the primaryAddressclass that is supported by this transport mapping.abstract voidlisten()Listen for incoming messages.abstract voidsendMessage(UdpAddress address, byte[] message, TransportStateReference tmStateReference, long timeoutMillis, int maxRetries)Sends a message to the supplied address using this transport.-
Methods inherited from class org.snmp4j.transport.AbstractTransportMapping
addTransportListener, fireProcessMessage, getMaxInboundMessageSize, isAsyncMsgProcessingSupported, removeTransportListener, setAsyncMsgProcessingSupported
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.snmp4j.TransportMapping
getSupportedAddressClasses, getSupportedTransportType, isAddressSupported, isAddressSupported, isListening
-
-
-
-
Field Detail
-
udpAddress
protected UdpAddress udpAddress
-
-
Constructor Detail
-
UdpTransportMapping
public UdpTransportMapping(UdpAddress udpAddress)
-
-
Method Detail
-
getSupportedAddressClass
public java.lang.Class<? extends Address> getSupportedAddressClass()
Description copied from interface:TransportMappingGets the primaryAddressclass that is supported by this transport mapping.- Specified by:
getSupportedAddressClassin interfaceTransportMapping<UdpAddress>- Specified by:
getSupportedAddressClassin classAbstractTransportMapping<UdpAddress>- Returns:
- a subclass of
Address.
-
getAddress
public UdpAddress getAddress()
Returns the transport address that is configured for this transport mapping for sending and receiving messages.- Returns:
- the
Addressused by this transport mapping. The returned instance must not be modified!
-
getListenAddress
public UdpAddress getListenAddress()
Description copied from interface:TransportMappingReturns the address that represents the actual incoming address this transport mapping uses to listen for incoming packets.- Returns:
- the address for incoming packets or
nullthis transport mapping is not configured to listen for incoming packets.
-
listen
public abstract void listen() throws java.io.IOExceptionDescription copied from interface:TransportMappingListen for incoming messages. For connection oriented transports, this method needs to be called beforeTransportMapping.sendMessage(A, byte[], org.snmp4j.TransportStateReference, long, int)is called for the first time.- Specified by:
listenin interfaceTransportMapping<UdpAddress>- Specified by:
listenin classAbstractTransportMapping<UdpAddress>- Throws:
java.io.IOException- if an IO operation exception occurs while starting the listener.
-
close
public abstract void close() throws java.io.IOExceptionDescription copied from interface:TransportMappingCloses the transport an releases all bound resources synchronously.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Specified by:
closein interfaceTransportMapping<UdpAddress>- Specified by:
closein classAbstractTransportMapping<UdpAddress>- Throws:
java.io.IOException- if any IO operation for the close fails.
-
sendMessage
public abstract void sendMessage(UdpAddress address, byte[] message, TransportStateReference tmStateReference, long timeoutMillis, int maxRetries) throws java.io.IOException
Description copied from interface:TransportMappingSends a message to the supplied address using this transport.- Specified by:
sendMessagein interfaceTransportMapping<UdpAddress>- Specified by:
sendMessagein classAbstractTransportMapping<UdpAddress>- Parameters:
address- anAddressinstance denoting the target address.message- the whole message as an array of bytes.tmStateReference- the (optional) transport model state reference as defined by RFC 5590 section 6.1.timeoutMillis- maximum number of milli seconds the connection creation might take (if connection based).maxRetries- maximum retries during connection creation.- Throws:
java.io.IOException- if any underlying IO operation fails.
-
-