Пример #1
0
        private int DoHandshake()
        {
            var data = BoltProtocolFactory.PackSupportedVersions();

            _tcpSocketClient.WriteStream.Write(data, 0, data.Length);
            _tcpSocketClient.WriteStream.Flush();
            _logger?.Debug("C: [HANDSHAKE] ", data);

            data = new byte[4];
            _tcpSocketClient.ReadStream.Read(data, 0, data.Length);

            var agreedVersion = BoltProtocolFactory.UnpackAgreedVersion(data);

            _logger?.Debug($"S: [HANDSHAKE] {agreedVersion}");
            return(agreedVersion);
        }
Пример #2
0
        private async Task <int> DoHandshakeAsync()
        {
            var data = BoltProtocolFactory.PackSupportedVersions();
            await _tcpSocketClient.WriteStream.WriteAsync(data, 0, data.Length).ConfigureAwait(false);

            await _tcpSocketClient.WriteStream.FlushAsync().ConfigureAwait(false);

            _logger?.Debug("C: [HANDSHAKE] ", data);

            data = new byte[4];
            await _tcpSocketClient.ReadStream.ReadAsync(data, 0, data.Length).ConfigureAwait(false);

            var agreedVersion = BoltProtocolFactory.UnpackAgreedVersion(data);

            _logger?.Debug($"S: [HANDSHAKE] {agreedVersion}");
            return(agreedVersion);
        }
Пример #3
0
        private async Task <BoltProtocolVersion> DoHandshakeAsync()
        {
            var data = BoltProtocolFactory.PackSupportedVersions(NumSupportedVersions);
            await _tcpSocketClient.WriteStream.WriteAsync(data, 0, data.Length).ConfigureAwait(false);

            await _tcpSocketClient.WriteStream.FlushAsync().ConfigureAwait(false);

            _logger?.Debug("C: [HANDSHAKE] {0}", data.ToHexString());

            data = new byte[4];
            var read = await _tcpSocketClient.ReadStream.ReadAsync(data, 0, data.Length).ConfigureAwait(false);

            if (read < data.Length)
            {
                throw new IOException($"Unexpected end of stream when performing handshake, read returned {read}");
            }

            var agreedVersion = BoltProtocolFactory.UnpackAgreedVersion(data);

            _logger?.Debug("S: [HANDSHAKE] {0}.{1}", agreedVersion.MajorVersion, agreedVersion.MinorVersion);
            return(agreedVersion);
        }