Exemple #1
0
        //初始化网络数据流
        private void InitNetStream()
        {
            int buffSize = 1024;

            byte[] tempBuf       = new byte[buffSize];
            byte[] fileNameArray = new byte[FileNameMaxLength];
            _netStream = new Utilities.NetStreamProcess();

            try
            {
                byte[] fileBytes = System.Text.Encoding.ASCII.GetBytes(this._fileName);
                fileBytes.CopyTo(fileNameArray, 0);
                _netStream.PushBytes(fileNameArray);
                _netStream.PushInt32(this._slot);
                _netStream.PushInt32(this._type == EndType.FPGA ? 1 : 2);
                //把fileStream的内容添加到MemoryStream
                _fileStream.Seek(0, SeekOrigin.Begin);
                while (true)
                {
                    int retSize = _fileStream.Read(tempBuf, 0, buffSize);
                    if (retSize == 0)
                    {
                        break;
                    }
                    _netStream.PushBytes(tempBuf, retSize);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("InitNetStream:" + e.Message);
            }
        }
            private void InitNetStream()
            {
                _netStream = new Utilities.NetStreamProcess();
                var cmdStream = _tcpCmd.GetNetStream();

                _netStream.PushInt32((int)base._Pack_StartCode);
                _netStream.PushInt32((int)base._Pack_Version);
                _netStream.PushInt32((int)base._Pack_Length);
                _netStream.PushInt32((int)(base._Pack_CmdID));

                _netStream.PushInt32((int)this._Pack_CmdCode);
                _netStream.PushInt32(0);
                if (cmdStream != null)
                {
                    cmdStream.WriteTo(_netStream);
                }
                _netStream.PushInt32((int)base._Pack_EndCode);
            }