0
최근에 libevent를 사용하는 작은 소켓 서버 프로그램이 있습니다.libevent는 열린 소켓 설명자를 읽을 수 없습니다.
요약하면 다음과 같은 작업을 수행합니다.
void read_function(int fd, short event, void* arg) {
printf("callback is called!\n");
// read from fd, and send a reply to fd!
}
void accept_thread_function() {
int fd = accept(...);
struct event* ev_read = new struct event();
memset(ev_read, 0, sizeof(struct event));
event_set(ev_read, fd, EV_READ|EV_PERSIST,read_function,ev_read);
event_add(ev_read, 0);
}
int main() {
event_init();
THREAD a = start 'accept_thread_function' as a thread;
event_dispatch();
THREAD::join(a);
}
문제는 read_function이 호출되지 않는다는 것입니다.
수신 연결이 올바르게 수락되었습니다. (한숨)
이 문제에 대한 친절한 의견을 기다리고 있습니다.
미리 감사드립니다.
감사합니다. Remi. 큰 논평이었습니다. –
어쨌든 libevent 대신 libev를 사용하도록 변경했습니다. libev는 나에게 많은 신뢰할만한 결과를 주었고 사용하기 쉬웠다. –