views:

91

answers:

1

Hi,

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...

+1  A: 

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.

caf
Thanks, I will use `pipe()` to old kernel versions and `eventfd()` to new kernel versions(I have found it in man pages.)adew
Andres Rodriguez