org.snmp4j.transport
Class TcpTransportMapping

java.lang.Object
  extended by org.snmp4j.transport.AbstractTransportMapping<TcpAddress>
      extended by org.snmp4j.transport.TcpTransportMapping
All Implemented Interfaces:
ConnectionOrientedTransportMapping<TcpAddress>, TransportMapping<TcpAddress>
Direct Known Subclasses:
DefaultTcpTransportMapping, TLSTM

public abstract class TcpTransportMapping
extends AbstractTransportMapping<TcpAddress>
implements ConnectionOrientedTransportMapping<TcpAddress>

The TcpTransportMapping is the abstract base class for TCP transport mappings.

Version:
1.7
Author:
Frank Fock

Field Summary
protected  TcpAddress tcpAddress
           
 
Fields inherited from class org.snmp4j.transport.AbstractTransportMapping
asyncMsgProcessingSupported, maxInboundMessageSize, transportListener
 
Constructor Summary
TcpTransportMapping(TcpAddress tcpAddress)
           
 
Method Summary
 void addTransportStateListener(TransportStateListener l)
          Adds a transport state listener that is to be informed about connection state changes.
abstract  void close()
          Closes the transport an releases all bound resources synchronously.
protected  void fireConnectionStateChanged(TransportStateEvent change)
           
 TcpAddress getAddress()
          Returns the transport address that is used by this transport mapping for sending and receiving messages.
 TcpAddress getListenAddress()
          Returns the address that represents the incoming address this transport mapping uses to listen for incoming packets.
abstract  MessageLengthDecoder getMessageLengthDecoder()
          Returns the MessageLengthDecoder used by this transport mapping.
 java.lang.Class<? extends Address> getSupportedAddressClass()
          Gets the Address class that is supported by this transport mapping.
abstract  void listen()
          Listen for incoming messages.
 void removeTransportStateListener(TransportStateListener l)
          Removes the supplied transport state listener.
abstract  void sendMessage(TcpAddress address, byte[] message, TransportStateReference tmStateReference)
          Sends a message to the supplied address using this transport.
abstract  void setConnectionTimeout(long connectionTimeout)
          Sets the connection timeout.
abstract  void setMessageLengthDecoder(MessageLengthDecoder messageLengthDecoder)
          Sets the MessageLengthDecoder that decodes the total message length from the header of a message.
 
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.transport.ConnectionOrientedTransportMapping
close
 
Methods inherited from interface org.snmp4j.TransportMapping
addTransportListener, getMaxInboundMessageSize, isListening, removeTransportListener
 

Field Detail

tcpAddress

protected TcpAddress tcpAddress
Constructor Detail

TcpTransportMapping

public TcpTransportMapping(TcpAddress tcpAddress)
Method Detail

getSupportedAddressClass

public java.lang.Class<? extends Address> getSupportedAddressClass()
Description copied from interface: TransportMapping
Gets the Address class that is supported by this transport mapping.

Specified by:
getSupportedAddressClass in interface TransportMapping<TcpAddress>
Specified by:
getSupportedAddressClass in class AbstractTransportMapping<TcpAddress>
Returns:
a subclass of Address.

getAddress

public TcpAddress getAddress()
Returns the transport address that is used by this transport mapping for sending and receiving messages.

Returns:
the Address used by this transport mapping. The returned instance must not be modified!

getListenAddress

public TcpAddress getListenAddress()
Description copied from interface: TransportMapping
Returns the address that represents the incoming address this transport mapping uses to listen for incoming packets.

Specified by:
getListenAddress in interface TransportMapping<TcpAddress>
Returns:
the address for incoming packets or null this transport mapping is not configured to listen for incoming packets.

sendMessage

public abstract void sendMessage(TcpAddress address,
                                 byte[] message,
                                 TransportStateReference tmStateReference)
                          throws java.io.IOException
Description copied from interface: TransportMapping
Sends a message to the supplied address using this transport.

Specified by:
sendMessage in interface TransportMapping<TcpAddress>
Specified by:
sendMessage in class AbstractTransportMapping<TcpAddress>
Parameters:
address - an Address instance 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.
Throws:
java.io.IOException - if any underlying IO operation fails.

listen

public abstract void listen()
                     throws java.io.IOException
Description copied from interface: TransportMapping
Listen for incoming messages. For connection oriented transports, this method needs to be called before TransportMapping.sendMessage(A, byte[], org.snmp4j.TransportStateReference) is called for the first time.

Specified by:
listen in interface TransportMapping<TcpAddress>
Specified by:
listen in class AbstractTransportMapping<TcpAddress>
Throws:
java.io.IOException - if an IO operation exception occurs while starting the listener.

close

public abstract void close()
                    throws java.io.IOException
Description copied from interface: TransportMapping
Closes the transport an releases all bound resources synchronously.

Specified by:
close in interface TransportMapping<TcpAddress>
Specified by:
close in class AbstractTransportMapping<TcpAddress>
Throws:
java.io.IOException - if any IO operation for the close fails.

getMessageLengthDecoder

public abstract MessageLengthDecoder getMessageLengthDecoder()
Returns the MessageLengthDecoder used by this transport mapping.

Specified by:
getMessageLengthDecoder in interface ConnectionOrientedTransportMapping<TcpAddress>
Returns:
a MessageLengthDecoder instance.
Since:
1.7

setMessageLengthDecoder

public abstract void setMessageLengthDecoder(MessageLengthDecoder messageLengthDecoder)
Sets the MessageLengthDecoder that decodes the total message length from the header of a message.

Specified by:
setMessageLengthDecoder in interface ConnectionOrientedTransportMapping<TcpAddress>
Parameters:
messageLengthDecoder - a MessageLengthDecoder instance.
Since:
1.7

setConnectionTimeout

public abstract void setConnectionTimeout(long connectionTimeout)
Sets the connection timeout. This timeout specifies the time a connection may be idle before it is closed.

Specified by:
setConnectionTimeout in interface ConnectionOrientedTransportMapping<TcpAddress>
Parameters:
connectionTimeout - the idle timeout in milliseconds. A zero or negative value will disable any timeout and connections opened by this transport mapping will stay opened until they are explicitly closed.
Since:
1.7

addTransportStateListener

public void addTransportStateListener(TransportStateListener l)
Description copied from interface: ConnectionOrientedTransportMapping
Adds a transport state listener that is to be informed about connection state changes.

Specified by:
addTransportStateListener in interface ConnectionOrientedTransportMapping<TcpAddress>
Parameters:
l - a TransportStateListener.

removeTransportStateListener

public void removeTransportStateListener(TransportStateListener l)
Description copied from interface: ConnectionOrientedTransportMapping
Removes the supplied transport state listener.

Specified by:
removeTransportStateListener in interface ConnectionOrientedTransportMapping<TcpAddress>
Parameters:
l - a TransportStateListener.

fireConnectionStateChanged

protected void fireConnectionStateChanged(TransportStateEvent change)

Copyright 2005-2011 Frank Fock (SNMP4J.org)

Copyright © 2011 SNMP4J.org. All Rights Reserved.