public class NatPmpDevice extends Object
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 and Description |
---|
NatPmpDevice(InetAddress gateway)
Constructs a new NatPmpDevice.
|
Modifier and Type | Method and Description |
---|---|
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.
|
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()
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()
Copyright © 2013. All Rights Reserved.