示例#1
0
        unsafe public int Read(byte *bufP, int count)
        {
            int r = 0;

            var fdarray = new PollFD[1];

            fdarray[0].fd     = Handle;
            fdarray[0].events = PollEvents.POLLIN | PollEvents.EPOLLRDHUP | PollEvents.EPOLLHUP | PollEvents.EPOLLERR;

            do
            {
                if (poll(fdarray, 1, -1) == -1)
                {
                    break;
                }
                if ((fdarray[0].revents & PollEvents.POLLIN) == 0)
                {
                    break;
                }
                r = (int)read(Handle, bufP, (SizeT)count);
            } while (r < 0 && UnixError.ShouldRetry);

            if (r < 0)
            {
                throw UnixError.GetLastUnixException();
            }

            return(r);
        }
示例#2
0
        /// <summary>
        /// Polls a File Descriptor for the passed in flags.
        /// </summary>
        /// <param name="fd">The descriptor to poll</param>
        /// <param name="flags">The flags to poll for</param>
        /// <param name="timeout">The amount of time to wait; -1 for infinite, 0 for immediate return, and a positive number is the number of milliseconds</param>
        /// <param name="resultFlags">The flags that were returned by the poll call</param>
        /// <returns>
        /// Returns a positive number (which is the number of structures with nonzero revent files), 0 for a timeout or no
        /// descriptors were ready, or -1 on error.
        /// </returns>
        internal static unsafe int Poll(int fd, PollFlags flags, int timeout, out PollFlags resultFlags)
        {
            PollFD pfd = default(PollFD);

            pfd.FD     = fd;
            pfd.Events = flags;
            int result = Poll(&pfd, 1, timeout);

            resultFlags = pfd.REvents;
            return(result);
        }
示例#3
0
 internal static unsafe extern int Poll(PollFD* pollData, uint numberOfPollFds, int timeout);