private static String getServerIP(int port) throws HeadlessException {
        BufferedReader in = null;
        try {
//            ip = InetAddress.getLocalHost().getHostAddress() + ":" + port;

            // Connect to website containing IP address.
            URL whatismyip = new URL("http://api.exip.org/?call=ip");
            in = new BufferedReader(new InputStreamReader(
                    whatismyip.openStream()));

            // Add port and return.
            return in.readLine() + ":" + port;

        } catch (IOException ex) {
            JOptionPane.showMessageDialog(null, "Error: " + ex.getMessage(), "Alert", JOptionPane.ERROR_MESSAGE);
        } finally {
            if (in != null)
                try {
                    in.close();
                } catch (IOException ex) {
                    // ignore
                }
        }

        // If unable to get address, return unknown.
        return "?:" + port;
    }