|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.snmp4j.transport.AbstractTransportMapping<UdpAddress>
org.snmp4j.transport.UdpTransportMapping
org.snmp4j.transport.DefaultUdpTransportMapping
public class DefaultUdpTransportMapping
The DefaultUdpTransportMapping implements a UDP transport
mapping based on Java standard IO and using an internal thread for
listening on the inbound socket.
| Field Summary | |
|---|---|
protected WorkerTask |
listener
|
protected org.snmp4j.transport.DefaultUdpTransportMapping.ListenThread |
listenerThread
|
protected java.net.DatagramSocket |
socket
|
| Fields inherited from class org.snmp4j.transport.UdpTransportMapping |
|---|
udpAddress |
| Fields inherited from class org.snmp4j.transport.AbstractTransportMapping |
|---|
asyncMsgProcessingSupported, maxInboundMessageSize, transportListener |
| Constructor Summary | |
|---|---|
DefaultUdpTransportMapping()
Creates a UDP transport with an arbitrary local port on all local interfaces. |
|
DefaultUdpTransportMapping(UdpAddress udpAddress)
Creates a UDP transport on the specified address. |
|
DefaultUdpTransportMapping(UdpAddress udpAddress,
boolean reuseAddress)
Creates a UDP transport with optional reusing the address if is currently in timeout state (TIME_WAIT) after the connection is closed. |
|
| Method Summary | |
|---|---|
void |
close()
Closes the socket and stops the listener thread. |
int |
getPriority()
Returns the priority of the internal listen thread. |
int |
getReceiveBufferSize()
Gets the requested receive buffer size for the underlying UDP socket. |
int |
getSocketTimeout()
Returns the socket timeout. |
java.lang.String |
getThreadName()
Returns the name of the listen thread. |
boolean |
isListening()
Returns true if the transport mapping is listening for
incoming messages. |
void |
listen()
Starts the listener thread that accepts incoming messages. |
void |
sendMessage(UdpAddress targetAddress,
byte[] message,
TransportStateReference tmStateReference)
Sends a message to the supplied address using this transport. |
void |
setMaxInboundMessageSize(int maxInboundMessageSize)
|
void |
setPriority(int newPriority)
Changes the priority of the listen thread for this UDP transport mapping. |
void |
setReceiveBufferSize(int receiveBufferSize)
Sets the receive buffer size, which should be > the maximum inbound message size. |
void |
setSocketTimeout(int socketTimeout)
Sets the socket timeout in milliseconds. |
void |
setThreadName(java.lang.String name)
Sets the name of the listen thread for this UDP transport mapping. |
| Methods inherited from class org.snmp4j.transport.UdpTransportMapping |
|---|
getAddress, getListenAddress, getSupportedAddressClass |
| 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 |
| Field Detail |
|---|
protected java.net.DatagramSocket socket
protected WorkerTask listener
protected org.snmp4j.transport.DefaultUdpTransportMapping.ListenThread listenerThread
| Constructor Detail |
|---|
public DefaultUdpTransportMapping()
throws java.io.IOException
java.io.IOException - if socket binding fails.
public DefaultUdpTransportMapping(UdpAddress udpAddress,
boolean reuseAddress)
throws java.io.IOException
udpAddress - the local address for sending and receiving of UDP messages.reuseAddress - if true addresses are reused which provides faster socket
binding if an application is restarted for instance.
java.io.IOException - if socket binding fails.
public DefaultUdpTransportMapping(UdpAddress udpAddress)
throws java.io.IOException
udpAddress - the local address for sending and receiving of UDP messages.
java.io.IOException - if socket binding fails.| Method Detail |
|---|
public void sendMessage(UdpAddress targetAddress,
byte[] message,
TransportStateReference tmStateReference)
throws java.io.IOException
TransportMapping
sendMessage in interface TransportMapping<UdpAddress>sendMessage in class UdpTransportMappingtargetAddress - 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.
java.io.IOException - if any underlying IO operation fails.
public void close()
throws java.io.IOException
close in interface TransportMapping<UdpAddress>close in class UdpTransportMappingjava.io.IOException
public void listen()
throws java.io.IOException
close() method should be called to stop the
listen thread gracefully and free associated ressources.
listen in interface TransportMapping<UdpAddress>listen in class UdpTransportMappingjava.io.IOExceptionpublic void setPriority(int newPriority)
listen() has been
called for this transport mapping.
newPriority - the new priority.Thread.setPriority(int)public int getPriority()
Thread.MIN_PRIORITY and
Thread.MAX_PRIORITY.public void setThreadName(java.lang.String name)
listen() has been
called for this transport mapping.
name - the new thread name.public java.lang.String getThreadName()
null.public void setMaxInboundMessageSize(int maxInboundMessageSize)
public int getSocketTimeout()
public int getReceiveBufferSize()
public void setReceiveBufferSize(int receiveBufferSize)
listen() to be
effective.
receiveBufferSize - an integer value >0 and > AbstractTransportMapping.getMaxInboundMessageSize().public void setSocketTimeout(int socketTimeout)
socketTimeout - the socket timeout for incoming messages in milliseconds.
A timeout of zero is interpreted as an infinite timeout.public boolean isListening()
TransportMappingtrue 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.
true if this transport mapping is listening for messages.
|
Copyright 2005-2011 Frank Fock (SNMP4J.org) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||