Esempio n. 1
0
        private void DoReceive(SocketReceived e, IActorRef handler)
        {
            if (e.IsIcmpError)
            {
                Log.Debug("Ignoring client connection reset.");
                ReceiveAsync();
                return;
            }

            if (e.SocketError != SocketError.Success)
            {
                throw new SocketException((int)e.SocketError);
            }

            handler.Tell(new Received(e.Data, e.RemoteEndPoint));
            ReceiveAsync();
        }
Esempio n. 2
0
        private void DoRead(SocketReceived received, IActorRef handler)
        {
            var e      = received.EventArgs;
            var buffer = new ByteBuffer(e.Buffer, e.Offset, e.BytesTransferred);
            var data   = new Received(ByteString.CopyFrom(buffer));

            Udp.BufferPool.Release(buffer);
            Udp.SocketEventArgsPool.Release(e);

            if (!_readingSuspended)
            {
                handler.Tell(data);
                ReceiveAsync();
            }
            else
            {
                _pendingRead = data;
            }
        }