org.snmp4j
Interface TransportMapping

All Known Subinterfaces:
ConnectionOrientedTransportMapping
All Known Implementing Classes:
AbstractTransportMapping, DefaultTcpTransportMapping, DefaultUdpTransportMapping, TcpTransportMapping, UdpTransportMapping

public interface TransportMapping

The TransportMapping defines the common interface for SNMP transport mappings. A transport mapping can only support a single transport protocol.

Version:
1.6
Author:
Frank Fock

Method Summary
 void addMessageDispatcher(MessageDispatcher dispatcher)
          Deprecated. Use addTransportListener(org.snmp4j.transport.TransportListener) instead. This method has been deprecated because the direct coupling between MessageDispatcher and TransportMappings is not flexible enough and prevents reusing TransportMappings for other purposes. This method will be removed with SNMP4J 2.0.
 void addTransportListener(TransportListener transportListener)
          Adds a transport listener to the transport.
 void close()
          Closes the transport an releases all bound resources synchronously.
 Address getListenAddress()
          Returns the address that represents the incoming address this transport mapping uses to listen for incoming packets.
 int getMaxInboundMessageSize()
          Gets the maximum length of an incoming message that can be successfully processed by this transport mapping implementation.
 java.lang.Class getSupportedAddressClass()
          Gets the Address class that is this transport mapping supports.
 boolean isListening()
          Returns true if the transport mapping is listening for incoming messages.
 void listen()
          Listen for incoming messages.
 void removeMessageDispatcher(MessageDispatcher dispatcher)
          Deprecated. Use removeTransportListener(org.snmp4j.transport.TransportListener) instead.
 void removeTransportListener(TransportListener transportListener)
          Removes a transport listener.
 void sendMessage(Address address, byte[] message)
          Sends a message to the supplied address using this transport.
 

Method Detail

getSupportedAddressClass

java.lang.Class getSupportedAddressClass()
Gets the Address class that is this transport mapping supports.

Returns:
a subclass of Address.

getListenAddress

Address getListenAddress()
Returns the address that represents the incoming address this transport mapping uses to listen for incoming packets.

Returns:
the address for incoming packets or null this transport mapping is not configured to listen for incoming packets.
Since:
1.6

sendMessage

void sendMessage(Address address,
                 byte[] message)
                 throws java.io.IOException
Sends a message to the supplied address using this transport.

Parameters:
address - an Address instance denoting the target address.
message - the whole message as an array of bytes.
Throws:
java.io.IOException

addMessageDispatcher

void addMessageDispatcher(MessageDispatcher dispatcher)
Deprecated. Use addTransportListener(org.snmp4j.transport.TransportListener) instead. This method has been deprecated because the direct coupling between MessageDispatcher and TransportMappings is not flexible enough and prevents reusing TransportMappings for other purposes. This method will be removed with SNMP4J 2.0.

Adds a message dispatcher to the transport. Normally, at least one message dispatcher needs to be added to process responses (or requests).

Parameters:
dispatcher - a MessageDispatcher instance.
See Also:
MessageDispatcherImpl

removeMessageDispatcher

void removeMessageDispatcher(MessageDispatcher dispatcher)
Deprecated. Use removeTransportListener(org.snmp4j.transport.TransportListener) instead.

Removes a message dispatcher. Incoming messages will no longer be propagated to the supplied message dispatcher.

Parameters:
dispatcher - a previously added MessageDispatcher instance.
See Also:
addMessageDispatcher(org.snmp4j.MessageDispatcher)

addTransportListener

void addTransportListener(TransportListener transportListener)
Adds a transport listener to the transport. Normally, at least one transport listener needs to be added to process incoming messages.

Parameters:
transportListener - a TransportListener instance.
Since:
1.6

removeTransportListener

void removeTransportListener(TransportListener transportListener)
Removes a transport listener. Incoming messages will no longer be propagated to the supplied TransportListener.

Parameters:
transportListener - a TransportListener instance.
Since:
1.6

close

void close()
           throws java.io.IOException
Closes the transport an releases all bound resources synchronously.

Throws:
java.io.IOException

listen

void listen()
            throws java.io.IOException
Listen for incoming messages. For connection oriented transports, this method needs to be called before sendMessage(org.snmp4j.smi.Address, byte[]) is called for the first time.

Throws:
java.io.IOException

isListening

boolean isListening()
Returns true if the transport mapping is listening for incoming messages. For connection oriented transport mappings this is a prerequisite to be able to send SNMP messages. For connectionless transport mappings it is a prerequisite to be able to receive responses.

Returns:
true if this transport mapping is listening for messages.
Since:
1.1

getMaxInboundMessageSize

int getMaxInboundMessageSize()
Gets the maximum length of an incoming message that can be successfully processed by this transport mapping implementation.

Returns:
an integer > 484.

Copyright 2005-2010 Frank Fock (SNMP4J.org)

Copyright © 2011 SNMP4J.org. All Rights Reserved.