Renci.SshNet.Common.SshDataStream.ReadUInt32 C# (CSharp) Method

ReadUInt32() public method

Reads the next uint data type from the SSH data stream.
public ReadUInt32 ( ) : uint
return uint
        public uint ReadUInt32()
        {
            var data = ReadBytes(4);
            return (uint) (data[0] << 24 | data[1] << 16 | data[2] << 8 | data[3]);
        }

Usage Example

        public void GetBytes()
        {
            var request = new SftpUnblockRequest(_protocolVersion, _requestId, _handle, _offset, _length, null);

            var bytes = request.GetBytes();

            var expectedBytesLength = 0;
            expectedBytesLength += 4; // Length
            expectedBytesLength += 1; // Type
            expectedBytesLength += 4; // RequestId
            expectedBytesLength += 4; // Handle length
            expectedBytesLength += _handle.Length; // Handle
            expectedBytesLength += 8; // Offset
            expectedBytesLength += 8; // Length

            Assert.AreEqual(expectedBytesLength, bytes.Length);

            var sshDataStream = new SshDataStream(bytes);

            Assert.AreEqual((uint) bytes.Length - 4, sshDataStream.ReadUInt32());
            Assert.AreEqual((byte) SftpMessageTypes.Unblock, sshDataStream.ReadByte());
            Assert.AreEqual(_requestId, sshDataStream.ReadUInt32());

            Assert.AreEqual((uint) _handle.Length, sshDataStream.ReadUInt32());
            var actualHandle = new byte[_handle.Length];
            sshDataStream.Read(actualHandle, 0, actualHandle.Length);
            Assert.IsTrue(_handle.SequenceEqual(actualHandle));

            Assert.AreEqual(_offset, sshDataStream.ReadUInt64());
            Assert.AreEqual(_length, sshDataStream.ReadUInt64());

            Assert.IsTrue(sshDataStream.IsEndOfData);
        }
All Usage Examples Of Renci.SshNet.Common.SshDataStream::ReadUInt32