public void sendMessage(byte[] msg){
        try {
            System.out.println(msg);
            client = new Socket("localhost",PORT);
            out = new DataOutputStream(client.getOutputStream());
            //Escribim text
            out.writeInt(msg.length);
            out.write(msg);
            out.flush();
            in = new BufferedReader(new InputStreamReader(client.getInputStream()));
            String dades = in.readLine();
            if (dades.trim()!="LOGIN ERROR") {
                this.token=dades;
                System.out.println("Nou token"+this.token);
            }
            System.out.println("Resposta: " + dades);
        } catch (UnknownHostException ex) {
            Logger.getLogger(AlkiriaClient.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(AlkiriaClient.class.getName()).log(Level.SEVERE, null, ex);
        }finally{
            try {
                out.close();
                client.close();
            } catch (IOException ex) {
                Logger.getLogger(AlkiriaClient.class.getName()).log(Level.SEVERE, null, ex);
            }
            
        }
        
    }