|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.sun.jaw.snmp.manager.SnmpSocket
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 SnmpConst.defaultSnmpResponsePktSize
. It can be
changed using setResponsePktSize(int)
.
Constructor Summary | |
SnmpSocket(DatagramHandlerIf rspHdlr)
Creates a new SnmpSocket object. |
Method Summary | |
void |
close()
Closes the socket and its associated resources. |
static SnmpSocket |
createNewDefaultSnmpSocket()
Creates a new SnmpSocket object. |
void |
deregister(java.lang.Object obj)
Removes the specified object to its list indicating that the object is using the socket. |
void |
finalize()
Closes the socket and its associated resources. |
java.util.Enumeration |
getAllRegisteredUsers()
Gets a list of objects (mostly SnmpSession objects), which
have registered to use this socket. |
static SnmpSocket |
getDefaultSnmpSocket()
Gets the default socket object. |
int |
getInPkts()
Gets the number of packets received. |
int |
getOutPkts()
Gets the number of packets sent. |
int |
getPktsErrors()
Gets the number of errors that occured. |
int |
getResponsePktSize()
Get the maximum size allowed for response packet. |
int |
getUserCount()
Gets the number of objects using this socket. |
boolean |
isValid()
Checks if the socket is initialised correctly and if it is still active. |
void |
performResetPktStatistics()
Reset all the counters. |
void |
register(java.lang.Object obj)
Adds the specified object to its list indicating that the object is using the socket. |
void |
run()
Dispatcher method for this socket thread. |
void |
sendPacket(byte[] buff,
int length,
java.net.InetAddress addr,
int port)
Sends a datagram packet to a specified device at specified port. |
void |
sendPacket(java.net.DatagramPacket dgrmpkt)
Sends a datagram packet to a specified device at specified port. |
void |
setDefaultSnmpSocket()
Defines the current socket as being the default one. |
void |
setResponsePktSize(int size)
Set the maximum size allowed for response packet. |
java.lang.String |
toString()
Returns the detailed statistics of the socket and activity stats. |
Methods inherited from class java.lang.Object |
clone,
equals,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Constructor Detail |
public SnmpSocket(DatagramHandlerIf rspHdlr) throws java.net.SocketException
SnmpSocket
object.rspHdlr
- A Datagram handler.Method Detail |
public static final SnmpSocket createNewDefaultSnmpSocket() throws java.net.SocketException
SnmpSocket
object.SnmpSocket
.public static final SnmpSocket getDefaultSnmpSocket()
public final void setDefaultSnmpSocket() throws java.net.SocketException
public final int getPktsErrors()
public final int getInPkts()
public final int getOutPkts()
public final void performResetPktStatistics()
public final java.util.Enumeration getAllRegisteredUsers()
SnmpSession
objects), which
have registered to use this socket.public final int getUserCount()
public java.lang.String toString()
public final void register(java.lang.Object obj)
obj
- The object to add.public final void deregister(java.lang.Object obj)
obj
- The object to be removed.public final int getResponsePktSize()
SnmpConst.defaultSnmpResponsePktSize
.public final void setResponsePktSize(int size)
public void sendPacket(byte[] buff, int length, java.net.InetAddress addr, int port) throws java.io.IOException
buff
- The packet data.length
- The packet length.addr
- The destination address.port
- The destination port number.public void sendPacket(java.net.DatagramPacket dgrmpkt) throws java.io.IOException
dgrmpkt
- The datagram packet.public void close()
Note: the default socket can not be closed directly through a
call to close
.
public boolean isValid()
public void run()
public void finalize()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |