简体   繁体   中英

How to assign event.ptr in epoll?

struct sockitem* NewSockItem(int sockfd, CallBack cb) {

    struct sockitem *si = (struct sockitem*)malloc(sizeof(struct sockitem));
    si->sockfd = sockfd;
    si->callback = cb;
    return si;
}

struct epoll_event ev;
ev.events = EPOLLIN | EPOLLET;
ev.events.ptr = NewSockItem(clientfd, recv_cb);

epoll_ctl(eventloop->epfd, EPOLL_CTL_ADD, clientfd, &ev);

when build, error happens like this:

enter image description here

use ev.data.ptr, not ev.events.ptr

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM