zan-extension/src/network/Socket.c
/**
 * Wait socket can read or write.
 */
Wait socket can read or write.
Wait socket can read or write .
int swSocket_wait(int fd, int timeout_ms, int events)
{
    struct pollfd event;
    event.fd = fd;
    event.events = 0;
    if (events & SW_EVENT_READ)
    {
        event.events |= POLLIN;
    }
    if (events & SW_EVENT_WRITE)
    {
        event.events |= POLLOUT;
    }
    while (1)
    {
        int ret = poll(&event, 1, timeout_ms);
        if (ret == 0)
        {
            return ZAN_ERR;
        }
        else if (ret < 0 && errno != EINTR)
        {
            zanError("poll() failed.");
            return ZAN_ERR;
        }
        else
        {
            return ZAN_OK;
        }
    }
    return ZAN_OK;
}
int swSocket_wait ( int fd , int timeout_ms , int events ) { struct pollfd event ; event . fd = fd ; event . events = 0 ; if ( events & SW_EVENT_READ ) { event . events |= POLLIN ; } if ( events & SW_EVENT_WRITE ) { event . events |= POLLOUT ; } while ( 1 ) { int ret = poll ( & event , 1 , timeout_ms ) ; if ( ret == 0 ) { return ZAN_ERR ; } else if ( ret < 0 && errno != EINTR ) { zanError ( " " ) ; return ZAN_ERR ; } else { return ZAN_OK ; } } return ZAN_OK ; }
Wait socket can read or write.
Wait socket can read or write .