private void reopenSocket() throws IOException{
        boolean error;
        do{
            try{
                if(sock != null){
                    close();
                }
                sock = new Socket(server, port);
                in = new BufferedInputStream(sock.getInputStream());
                os = new BufferedOutputStream(sock.getOutputStream());
                error = false;
            }catch(IOException e){
                int handle = -1;
                if(errorHandler == null || (handle = errorHandler.handle(e)) == -1){
                    throw e;
                }
                error = true;
                if(handle != -1){
                    try {
                        Thread.sleep(handle);
                    } catch (InterruptedException ex) {
                        throw new IOException(ex);
                    }
                }
            }
        }while(error);
        
    }