private void Send()
        {
            var buffer = new Buffer();

            buffer.SetString("hello");
            _client.Send(buffer);
        }
Beispiel #2
0
        public void Send()
        {
            var buffer = new Buffer();

            FillMemory(buffer);
            _behavior.Send(buffer);
            ReceiveAndVerify();
        }
Beispiel #3
0
        public void TrySend()
        {
            var buffer = new Buffer();

            FillMemory(buffer);
            var result = _behavior.TrySend(buffer);

            result.Should().BeTrue();
            ReceiveAndVerify();
        }
        public Buffer Receive()
        {
            var buffer = new Buffer(128); // todo

            var sizePtr = (UIntPtr)buffer.Length;

            NativeMethods.nng_recv(_nngSocket, buffer.Ptr, ref sizePtr, default).ThrowIfError();

            buffer.Length = (int)sizePtr;
            return(buffer);
        }
        public bool TryReceive(out Buffer buffer)
        {
            buffer = new Buffer(128); // todo

            var sizePtr   = (UIntPtr)buffer.Length;
            var errorCode = NativeMethods.nng_recv(_nngSocket, buffer.Ptr, ref sizePtr, NativeMethods.NngFlags.Async);

            if (errorCode == NngErrorCode.TryAgain)
            {
                buffer = null;
                return(false);
            }
            errorCode.ThrowIfError();

            buffer.Length = (int)sizePtr;
            return(true);
        }
 public void Send(Buffer buffer)
 {
     NativeMethods.nng_send(_nngSocket, buffer.Ptr, (UIntPtr)buffer.Length, default).ThrowIfError();