Beispiel #1
0
        private void rcallback(IntPtr streamPointer, IntPtr size)
        {
            long nread = size.ToInt64();

            if (nread == 0)
            {
                return;
            }
            else if (nread < 0)
            {
                if (UVException.Map((int)nread) == UVErrorCode.EOF)
                {
                    Close(Complete);
                }
                else
                {
                    OnError(Ensure.Map((int)nread));
                    Close();
                }
            }
            else
            {
                OnData(ByteBufferAllocator.Retrieve(size.ToInt32()));
            }
        }
Beispiel #2
0
        private void recv_callback(IntPtr handle, IntPtr nread, IntPtr sockaddr, ushort flags)
        {
            int n = (int)nread;

            if (n == 0)
            {
                return;
            }

            if (Message != null)
            {
                var ep = UV.GetIPEndPoint(sockaddr, true);

                var msg = new UdpReceiveMessage(
                    ep,
                    ByteBufferAllocator.Retrieve(n),
                    (flags & (short)uv_udp_flags.UV_UDP_PARTIAL) > 0
                    );

                Message(msg);
            }
        }