@Override
    public void run() {

        /*String line;
        Scanner s = new Scanner(System.in);
        while (true) {
            try {
                line = s.nextLine();
                if (line.equals("")) {
                    break;
                }
            } catch (NoSuchElementException e) {
                // Ukoncena aplikace. OK.
            }

        }*/

        if (packet != null) {
            //stdOut.writeln(TAG + " reading file " + file);
            Node nextNode = null;
            try {

                //Packet packet = PacketFileReader.readPacketFromFile(file, serverNode);
                stdOut.writeln(TAG + " client packet: " + packet);
                nextNode = RoutingManager.nextNode(packet);
                stdOut.writeln(TAG + " next node: " + nextNode);

                socketChannel = SocketChannel.open();
                socketChannel.configureBlocking(true);

                socketChannel.connect(new InetSocketAddress(nextNode.getAddress(), nextNode.getPort()));
                stdOut.writeln(TAG + " connected to: " + nextNode);
                BufferedWriter bf;
                try {
                    bf = new BufferedWriter(new OutputStreamWriter(socketChannel.socket().getOutputStream()));
                    bf.write(gson.toJson(packet));
                    bf.close();
                } catch (IOException e) {
                    stdOut.printError(TAG + " cannot write to the socket");
                }


            } catch (IOException e1) {
                stdOut.printError(TAG + " can not connect to: " + nextNode);
            }
            try {
                socketChannel.close();
            } catch (IOException e) {
               //OK
            }
        }
        stdOut.writeln(TAG + " client end");

    }