@Override
    public void run() {
        try {
            socket = new Socket(server, port);
            reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
            writer = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
            String line;
            if (socket.isConnected()) {
                send("NICK " + nicks[0]);
                send("USER " + nicks[0] + " 8 * :" + real);
                while ((line = reader.readLine()) != null) {
                    //if (!this.isConnected) break;
                    parseFromServer(line);
                }

            }
        } catch (IOException ex) {
            System.out.println("socket io exception");
        } catch (BadLocationException ex) {
            Logger.getLogger(Connection.class.getName()).log(Level.SEVERE, null, ex);
        }
    }