Client connections with epoll
I'm programming an application(client/server) in C++ for linux using epoll y pthreads but I don't know how to handle the connect()
calls for attach a new connection in the descriptor list if a loop with epoll_wait()
is running(Edge-triggered), How to can I do it?... I could to use a dummy file descriptor to trigger an event and scape of wait?, or a simple call to connect()
could fire the event??...
Sorry for my bad开发者_运维技巧 english...
Yes, you can use another file descriptor that's just for waking up your epoll_wait()
loop. Use pipe()
to create the file descriptor. Add the reading end of the pipe to your epoll
list, and write a single byte to the writing end when you want to wake it up. The reading side can just read that byte and discard it.
精彩评论