All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.sun.jaw.snmp.manager.SnmpSocket

java.lang.Object
   |
   +----com.sun.jaw.snmp.manager.SnmpSocket

public final class SnmpSocket
extends Object
implements Runnable
This class creates a SNMP Datagram Socket. This class has methods helpful to send SNMP packets to an arbitrary port of a specified device. It also runs a thread that is devoted to receiving messages on the socket. It marks a socket as a default socket. All operations are directed to the this default socket.
A user can create a new socket and use it exclusively for certain operations.
A socket imposes an upper limit on size of response packet. Any packet which exceeds this limit is truncated. By default, this limit is {@link SnmpConst#defaultSnmpResponsePktSize}. It can be changed using {@link #setResponsePktSize}.


Constructor Index

 o SnmpSocket(DatagramHandlerIf)
Creates a new SnmpSocket object.

Method Index

 o close()
Closes the socket and its associated resources.
 o createNewDefaultSnmpSocket()
Creates a new SnmpSocket object.
 o deregister(Object)
Removes the specified object to its list indicating that the object is using the socket.
 o finalize()
Closes the socket and its associated resources.
 o getAllRegisteredUsers()
Gets a list of objects (mostly SnmpSession objects), which have registered to use this socket.
 o getDefaultSnmpSocket()
Gets the default socket object.
 o getInPkts()
Gets the number of packets received.
 o getOutPkts()
Gets the number of packets sent.
 o getPktsErrors()
Gets the number of errors that occured.
 o getResponsePktSize()
Get the maximum size allowed for response packet.
 o getUserCount()
Gets the number of objects using this socket.
 o isValid()
Checks if the socket is initialised correctly and if it is still active.
 o performResetPktStatistics()
Reset all the counters.
 o register(Object)
Adds the specified object to its list indicating that the object is using the socket.
 o run()
Dispatcher method for this socket thread.
 o sendPacket(byte[], int, InetAddress, int)
Sends a datagram packet to a specified device at specified port.
 o sendPacket(DatagramPacket)
Sends a datagram packet to a specified device at specified port.
 o setDefaultSnmpSocket()
Defines the current socket as being the default one.
 o setResponsePktSize(int)
Set the maximum size allowed for response packet.
 o toString()
Returns the detailed statistics of the socket and activity stats.

Constructors

 o SnmpSocket
 public SnmpSocket(DatagramHandlerIf rspHdlr) throws SocketException
Creates a new SnmpSocket object.

Parameters:
rspHdlr - A Datagram handler.
Throws: SocketException
A socket could not be created.

Methods

 o createNewDefaultSnmpSocket
 public static final synchronized SnmpSocket createNewDefaultSnmpSocket() throws SocketException
Creates a new SnmpSocket object.

Returns:
The new SnmpSocket.
Throws: SocketException
A socket could not be created.
 o getDefaultSnmpSocket
 public static final SnmpSocket getDefaultSnmpSocket()
Gets the default socket object.

Returns:
The default socket object.
 o setDefaultSnmpSocket
 public final synchronized void setDefaultSnmpSocket() throws SocketException
Defines the current socket as being the default one.

Throws: SocketException
A socket could not be created.
 o getPktsErrors
 public final synchronized int getPktsErrors()
Gets the number of errors that occured.

Returns:
The number of errors that occured.
 o getInPkts
 public final synchronized int getInPkts()
Gets the number of packets received.

Returns:
The number of packets received.
 o getOutPkts
 public final synchronized int getOutPkts()
Gets the number of packets sent.

Returns:
The number of packets sent.
 o performResetPktStatistics
 public final synchronized void performResetPktStatistics()
Reset all the counters.

 o getAllRegisteredUsers
 public final synchronized Enumeration getAllRegisteredUsers()
Gets a list of objects (mostly SnmpSession objects), which have registered to use this socket.

Returns:
Enumeration which gives a list of all users using this socket.
 o getUserCount
 public final synchronized int getUserCount()
Gets the number of objects using this socket.

Returns:
The count of objects using this socket.
 o toString
 public synchronized String toString()
Returns the detailed statistics of the socket and activity stats.

Returns:
The detailed statistics of the socket and activity stats.
Overrides:
toString in class Object
 o register
 public final synchronized void register(Object obj)
Adds the specified object to its list indicating that the object is using the socket. This method is similar to reference counting.

Parameters:
obj - The object to add.
 o deregister
 public final synchronized void deregister(Object obj)
Removes the specified object to its list indicating that the object is using the socket.

Parameters:
obj - The object to be removed.
 o getResponsePktSize
 public final int getResponsePktSize()
Get the maximum size allowed for response packet. Any packet which exceeds this limit will be truncated. The default value is {@link SnmpConst#defaultSnmpResponsePktSize}.

 o setResponsePktSize
 public final synchronized void setResponsePktSize(int size)
Set the maximum size allowed for response packet.

 o sendPacket
 public synchronized void sendPacket(byte buff[],
                                     int length,
                                     InetAddress addr,
                                     int port) throws IOException
Sends a datagram packet to a specified device at specified port. It also updates packet statistics.

Parameters:
buff - The packet data.
length - The packet length.
addr - The destination address.
port - The destination port number.
Throws: IOException
Signals that an I/O exception of some sort has occurred.
 o sendPacket
 public synchronized void sendPacket(DatagramPacket dgrmpkt) throws IOException
Sends a datagram packet to a specified device at specified port. It also updates packet statistics.

Parameters:
dgrmpkt - The datagram packet.
Throws: IOException
Signals that an I/O exception of some sort has occurred.
 o close
 public synchronized void close()
Closes the socket and its associated resources.

Note: the default socket can not be closed directly through a call to close.

 o isValid
 public synchronized boolean isValid()
Checks if the socket is initialised correctly and if it is still active.

Returns:
True if the socket is initialised correctly and if it is still active; false otherwise.
 o run
 public void run()
Dispatcher method for this socket thread. This is the dispatcher method which goes in an endless-loop and waits for receiving datagram packets on the socket.

 o finalize
 public synchronized void finalize()
Closes the socket and its associated resources.

Overrides:
finalize in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index