How to get errno when epoll_wait returns EPOLLERR?

前端 未结 4 1296
鱼传尺愫
鱼传尺愫 2021-02-07 12:51

Is there a way to find out the errno when epoll_wait returns EPOLLERR for a particular fd?

Is there any further information about

4条回答
  •  遇见更好的自我
    2021-02-07 13:35

    Use getsockopt and SO_ERROR to get the pending error on the socket

    int       error = 0;
    socklen_t errlen = sizeof(error);
    if (getsockopt(fd, SOL_SOCKET, SO_ERROR, (void *)&error, &errlen) == 0)
    {
        printf("error = %s\n", strerror(error));
    }
    

提交回复
热议问题