public Client(String IPAddress, int port) throws IOException{
        socket = new Socket(IPAddress, port);
        messages = new LinkedBlockingQueue<Object>();
        server = new ConnectionToServer(socket);

        Thread messageHandling = new Thread() {
            public void run(){
                while(true){
                    try{
                        Object message = messages.take();
                        // Do some handling here...
                        if(message instanceof Message){
                            Message m=(Message)message;
                            if(m.getHeader().equals("quit"))
                                running=false;
                            else if(m.getHeader().equals("message")){
                                e=new Enigma(rotors, seed,offsets);
                                System.out.println(new String(e.cypher((byte[])m.getData())));
                            }else if(m.getHeader().equals("file")){
                                e=new Enigma(rotors, seed,offsets);
                                OutputStream fout=new FileOutputStream("out");
                                fout.write(e.cypher((byte[])m.getData()));
                                fout.close();
                                System.out.println("File!!!");
                            }
                        }
                    } catch (FileNotFoundException ex) {
                        Logger.getLogger(Client.class.getName()).log(Level.SEVERE, null, ex);
                    } catch (InterruptedException ex) {
                        Logger.getLogger(Client.class.getName()).log(Level.SEVERE, null, ex);
                    } catch (IOException ex) {
                        Logger.getLogger(Client.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
            }
        };

        messageHandling.setDaemon(true);
        messageHandling.start();
    }