예제 #1
0
    bool UpdateStream(out UInt16 flag, out ViIStream IS)
    {
        flag = 0;
        IS   = null;
        NetworkStream stream = _client.GetStream();

        if (_receiver.Size == 0)
        {
            if (_client.Available < RECEIVE_HEAD_SIZE)
            {
                return(false);
            }
            SetConnectState(true);
            int    bufferSize = stream.Read(_receiveHead, 0, RECEIVE_HEAD_SIZE);
            UInt16 flag_      = ViBitConverter.ToUInt16(_receiveHead, 0);
            UInt32 size       = ViBitConverter.ToUInt32(_receiveHead, RECEIVE_SIZE_OFFSET);
            _receiver.SetCompleteSize(flag_, size);
        }
        _receiver.Read(stream);
        if (_receiver.IsComplete == false)
        {
            return(false);
        }
        _IS.Init(_receiver.Data, _receiver.Size);
        _receiver.Clear();
        IS = _IS;
        return(true);
    }
예제 #2
0
 public bool Read(out UInt32 value)
 {
     if (_offset + 4 > _len)
     {
         ViDebuger.Warning("Read Fail UInt32");
         value   = 0;
         _offset = _len;
         return(false);
     }
     value = ViBitConverter.ToUInt32(_buffer, _offset);
     _Print("UInt32", value);
     _offset += 4;
     return(true);
 }