Esempio n. 1
0
        override public bool pkt_proc(byte[] buf)
        {
            if (buf == null)
            {
                pktbuf = new pkt_rdq(dirname).pack();
                uc.Send(pktbuf, pktbuf.Length, r);
                return(true);
            }
            if (blkno == 0)
            {
                blkno++;
            }
            pkt_data pkt = new pkt_data();

            if (!pkt.parse(buf))
            {
                return(false);
            }
            if (pkt.blkno != (blkno & 0xffff))
            {
                return(true);  // ignore expired data?
            }
            filesize += pkt.data.Length;
            if (pkt.data.Length > 0)
            {
                dirinfo = Encoding.Default.GetString(pkt.data);
            }
            pktbuf = new pkt_ack(blkno++).pack();
            uc.Send(pktbuf, pktbuf.Length, r);
            return(false);
        }
Esempio n. 2
0
        override public bool pkt_proc(byte[] buf)
        {
            Opcodes op = (Opcodes)buf[1];

            if (op != Opcodes.ReadDir)
            {
                return(false);
            }
            pkt_rdq pkt = new pkt_rdq();

            if (!pkt.parse(buf))
            {
                return(false);
            }
            dirname = pkt.dirname;
            read_dir(dirname, ref dirinfo);
            pktbuf   = new pkt_data(++blkno, Encoding.Default.GetBytes(dirinfo)).pack();
            curretry = 0;   // reset retry cnt
            return(uc.Send(pktbuf, pktbuf.Length, r) == pktbuf.Length);
        }