Brod.Network.Socket.Recv C# (CSharp) Метод

Recv() публичный Метод

public Recv ( ) : byte[]
Результат byte[]
        public byte[] Recv()
        {
            return _zmqSocket.Recv();
        }

Same methods

Socket::Recv ( Int32 timeout ) : byte[]

Usage Example

Пример #1
0
        public void Run(CancellationToken token)
        {
            using (Socket socket = CreateSocket(_socketType))
            {
                // Bind to address
                socket.Bind(_address);

                // Process while canellation not requested
                while (!token.IsCancellationRequested)
                {
                    // Waits for messages
                    var data = socket.Recv();
                    if (data == null)
                    {
                        continue;
                    }

                    Response response = null;

                    using (var buffer = new BinaryMemoryStream(data))
                    {
                        // by request type we can distinguish actual request
                        var requestType = (RequestType)buffer.Reader.ReadInt16();
                        var handler     = _handlerMapping(requestType, buffer);

                        response = handler(buffer);
                    }

                    if (response != null)
                    {
                        using (var buffer = new BinaryMemoryStream())
                        {
                            buffer.Writer.Write((short)response.ResponseType);
                            response.WriteToStream(buffer);
                            socket.Send(buffer.ToArray());
                        }
                    }
                }
            }
        }
All Usage Examples Of Brod.Network.Socket::Recv