|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.tomp2p.natpmp.NatPmpDevice
public class NatPmpDevice
This class manages a NAT-PMP device. This class is thread-safe. This manages communication with a NAT-PMP device on
the network. There are two types of messages that can be sent to the device. ExternalAddressRequestMessage
can be sent to get the external IP of the gateway. MapRequestMessage
can be sent to map a port for a certain
amount of time. These two messages can be put into the message queue through the enqueueMessage(Message)
method. As this class manages a message queue to the NAT-PMP device, it is important to shut it down correctly. Any
mapped ports that are no longer desired should be unmapped before shutdown occurs. Refer to
#NatPmpDevice(boolean)
for details about the shutdown mechanism.
Constructor Summary | |
---|---|
NatPmpDevice(InetAddress gateway)
Constructs a new NatPmpDevice. |
Method Summary | |
---|---|
void |
clearQueue()
Clears the queue of messages to send. |
void |
enqueueMessage(Message message)
Enqueues a message for sending. |
boolean |
isShutdown()
Flag indicates if this NatPmpDevice is shutdown. |
void |
shutdown()
Shuts down this NatPmpDevice. |
void |
waitUntilQueueEmpty()
Synchronously waits until the queue is empty before returning. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public NatPmpDevice(InetAddress gateway) throws NatPmpException
shutdownHookEnabled
- Shutting down existing port mappings is a desired behavior; therefore, this value is
required! Refer to #setShutdownHookEnabled(boolean)
for details about what value should be
provided here and how it alters the object's behavior.
NatPmpException
- A NatPmpException may be thrown if the local network is not using addresses defined in
RFC1918. A NatPmpException may also be thrown if the the network gateway cannot be determined, which
may rarely be due to the network not using IPv4. NAT-PMP should only be used on RFC1918 networks
using IPv4.#setShutdownHookEnabled(boolean)
,
shutdown()
Method Detail |
---|
public void enqueueMessage(Message message)
message
- The Message
to send.clearQueue()
public void clearQueue()
enqueueMessage(Message)
public void waitUntilQueueEmpty()
public void shutdown()
#shutdownAsync(boolean)
method should be
called.
isShutdown()
,
#setShutdownHookEnabled(boolean)
,
#shutdownAsync(boolean)
public boolean isShutdown()
Thread
instead.
shutdown()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |