com.adventnet.snmp.snmp2
Class TcpProtocolOptionsImpl

java.lang.Object
  |
  +--com.adventnet.snmp.snmp2.TcpProtocolOptionsImpl
All Implemented Interfaces:
ProtocolOptions

public class TcpProtocolOptionsImpl
extends java.lang.Object
implements ProtocolOptions

Implemention of the ProtocolOptions interface for TCP/IP protocol.


Constructor Summary
TcpProtocolOptionsImpl()
          The default constructor which will assign default values to all the variables in this class.
TcpProtocolOptionsImpl(java.net.InetAddress remoteAddress, int remotePort)
          Constructs a new TcpProtocolOptions object with remoteAddress and remotePort as target host and port.
TcpProtocolOptionsImpl(java.lang.String remoteHost, int remotePort)
          Constructor that creates TcpProtocolOptionsImpl with remoteHost and remotePort as target host and port.
TcpProtocolOptionsImpl(java.lang.String remoteHost, int remotePort, int localPort)
          Constructor that creates the TcpProtocolOptionsImpl object.
 
Method Summary
 java.lang.String getLocalAddress()
          Get the local address configured.
 int getLocalPort()
          Get the local port configured.
 int getReceiveBufferSize()
          This method returns the previously set buffer size or zero.
 java.net.InetAddress getRemoteAddress()
          This method gets the remoteAddress as an InetAddress object.
 java.lang.String getRemoteHost()
          Get the remote host with which this SNMP entity will communicate.
 int getRemotePort()
          Get the remote port with which this SNMP entity will communicate.
 java.lang.String getSessionId()
          Get a unique session id that is associated with each SNMP session initiated from this SNMP entity.
 void setLocalPort(int port)
          This method sets the local port on which the session should be opened.
 void setReceiveBufferSize(int size)
          This method sets the buffer size of this receiver when the receiver is ready for receiving the next packet.
 void setRemoteHost(java.lang.String host)
          This method sets the remoteHost to this TcpProtocolOptionsImpl object.
 void setRemotePort(int port)
          This method sets the remotePort to which the SNMP packets should be sent.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TcpProtocolOptionsImpl

public TcpProtocolOptionsImpl()
The default constructor which will assign default values to all the variables in this class.

Since:
AdventNet SNMP API 4 SP4 ( Release 4.0.4 )

TcpProtocolOptionsImpl

public TcpProtocolOptionsImpl(java.lang.String remoteHost,
                              int remotePort,
                              int localPort)
Constructor that creates the TcpProtocolOptionsImpl object.


TcpProtocolOptionsImpl

public TcpProtocolOptionsImpl(java.lang.String remoteHost,
                              int remotePort)
Constructor that creates TcpProtocolOptionsImpl with remoteHost and remotePort as target host and port.

Since:
AdventNet SNMP API 4 SP4 ( Release 4.0.4 )

TcpProtocolOptionsImpl

public TcpProtocolOptionsImpl(java.net.InetAddress remoteAddress,
                              int remotePort)
Constructs a new TcpProtocolOptions object with remoteAddress and remotePort as target host and port.

Parameters:
remoteAddress - the target address to which a SNMP request is to be sent.
remotePort - the target port to which a SNMP request is to be sent.
Throws:
java.lang.IllegalArgumentException - If remoteAddress is null.
If the remotePort is less than zero or greater than 65535.
Since:
AdventNet SNMP API 4 SP4 ( Release 4.0.4 )
Method Detail

getRemoteHost

public java.lang.String getRemoteHost()
Get the remote host with which this SNMP entity will communicate.


setRemoteHost

public void setRemoteHost(java.lang.String host)
This method sets the remoteHost to this TcpProtocolOptionsImpl object.

Parameters:
host - The remoteHost that is to be set.
Since:
AdventNet SNMP API 4 SP4 ( Release 4.0.4 )

getRemotePort

public int getRemotePort()
Get the remote port with which this SNMP entity will communicate.


getLocalPort

public int getLocalPort()
Get the local port configured.


setRemotePort

public void setRemotePort(int port)
This method sets the remotePort to which the SNMP packets should be sent.

Parameters:
port - the remote port to which the SNMP packet should be sent.
Throws:
java.lang.IllegalArgumentException - If the port is negative or greater than 65535.
Since:
AdventNet SNMP API 4 SP4 ( Release 4.0.4 )

setLocalPort

public void setLocalPort(int port)
This method sets the local port on which the session should be opened. For a session to be opened in a particular port, then this local port should be specified and this TcpProtocolOptions instance should be set on the session.

Parameters:
port - the port at which the session should be opened.
Throws:
java.lang.IllegalArgumentException - If the port is negative or greater than 65535.
Since:
AdventNet SNMP API 4 SP4 ( Release 4.0.4 )

getLocalAddress

public java.lang.String getLocalAddress()
Get the local address configured.


setReceiveBufferSize

public void setReceiveBufferSize(int size)
This method sets the buffer size of this receiver when the receiver is ready for receiving the next packet. It should be called before the "open()" of SnmpSession is called. If it is called after it, then this new value will come into effect only for the next packet that is to be received.

The following should be done to set the receive buffer size in the SnmpTransportProvider.
TcpProtocolOptions opt = (TcpProtocolOptions)session.getProtocolOptions();
if(opt != null)
{
opt.setReceiveBufferSize(size);
}
else
{
TcpProtocolOptions opt = new TcpProtocolOptions();
opt.setReceiveBufferSize(size);
session.setProtocolOptions(opt);
}
Usaually the protocolOptions in the session will not be null, unless session.setProtocolOptions() is called with a null value.

This method will accept only values that are greater than zero. If the value is less than or equal to zero, then an IllegalArgumentException will be thrown. The validity of the value that is passed should be done by the user. Any invalid value that is passed will not be set on the SnmpTransportProvider.

Parameters:
size - the size of the buffer.
Throws:
java.lang.IllegalArgumentException - if the value is 0 or is negative.
Since:
AdventNet SNMP API 4 SP4 ( Release 4.0.4 )

getReceiveBufferSize

public int getReceiveBufferSize()
This method returns the previously set buffer size or zero.

The TcpProtocolOptionsImpl object that is used to open the SnmpSession will return the present buffer size of the socket.

Returns:
the buffer size of this receiver.
Since:
AdventNet SNMP API 4 SP4 ( Release 4.0.4 )

getSessionId

public java.lang.String getSessionId()
Get a unique session id that is associated with each SNMP session initiated from this SNMP entity. This is used by the SNMP v3 module. For example, this can even be a combination of the host and port.

Specified by:
getSessionId in interface ProtocolOptions

getRemoteAddress

public java.net.InetAddress getRemoteAddress()
This method gets the remoteAddress as an InetAddress object.

Returns:
the remote address that is set previously.


Copyright (c)AdventNet Inc., 1996-2006