public static boolean connection() {
        Socket socket=null;
        boolean reachable=false;
        //Poizkusi poslati paket do strežnika. Če se strežnik odzove,
        //Potem ima program internetno povezavo, drugače pa ne
        try {
            socket=new Socket(Main.ip, 80);
            reachable=true;
        } catch (Exception e) {}
        finally {
            if (socket!=null) try {socket.close();} catch (Exception e) {}
        }

        return reachable;
    }