public class UPnP extends Object
| Constructor and Description |
|---|
UPnP() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
closePortTCP(int port)
Closes a TCP port on the gateway.
Some routers seem to refuse to do this. |
static boolean |
closePortUDP(int port)
Closes a UDP port on the gateway.
Some routers seem to refuse to do this. |
static String |
getDefaultGatewayIP()
Gets the internal IP address of the router.
192.168.1.1 is typically the default IP address for most SOHO (Small Office Home Office) routers. |
static String |
getExternalIP()
Gets the external IP address of the default gateway.
This is the public IP address that is assigned to your router by your Internet Service Provider. |
static String |
getLocalIP()
Gets the IP address of the machine or device that your
program is currently running on.
If this is the first method called after your program starts, it will take a while because it first needs to run isUPnPAvailable(). |
static boolean |
isMappedTCP(int port)
Checks if a TCP port is mapped.
If this is the first method called after your program starts, it will take a while because it first needs to run isUPnPAvailable(). |
static boolean |
isMappedUDP(int port)
Checks if a UDP port is mapped.
If this is the first method called after your program starts, it will take a while because it first needs to run isUPnPAvailable(). |
static boolean |
isUPnPAvailable()
This method gets your computer or devices configured
default gateway (usually 192.168.1.1 by default on
most SOHO routers) and it queries it to find out if
the UPnP service is enabled.
|
static boolean |
openPortTCP(int port)
Opens a TCP port on the gateway.
If this is the first method called after your program starts, it will take a while because it first needs to run isUPnPAvailable(). |
static boolean |
openPortUDP(int port)
Opens a UDP port on the gateway.
If this is the first method called after your program starts, it will take a while because it first needs to run isUPnPAvailable(). |
public static boolean isUPnPAvailable()
public static boolean openPortTCP(int port)
port - TCP port (0-65535)public static boolean openPortUDP(int port)
port - UDP port (0-65535)public static boolean closePortTCP(int port)
port - TCP port (0-65535)public static boolean closePortUDP(int port)
port - UDP port (0-65535)public static boolean isMappedTCP(int port)
port - TCP port (0-65535)public static boolean isMappedUDP(int port)
port - UDP port (0-65535)public static String getExternalIP()
public static String getLocalIP()
public static String getDefaultGatewayIP()
Copyright © 2022. All rights reserved.