Richard,

I'm using libEvent to write a streaming media server, mainly to test
epoll() on Linux / kqueue on Mac OSX / etc. for scalability.  Right
now, my test server waits for n connections to be established (n
specified on the command line), calling event_add() for each
connection, then calls event_dispatch() and sends bytes to each
client.  The sockets are non-blocking, but right now, event_dispatch
() blocks until all clients have received all of the bytes (i'm
streaming a 40MB MPEG file for now as a test).  I would like to have
the number of connections be more variable, so I want to continue
accepting new connections from other clients, while i'm handling
events for the ones I have.  However, since event_dispatch() is
blocking, my accept() isn't happening.

I could solve this by adding another thread (assuming libEvent is
thread-safe), but i'd rather not do that.  Can I make event_dispatch
() not block, or is there some other way to do what I want to do?


Make the socket you accept on non blocking and register a read callback for
it. Accept new connections in the callback.

Yes, I can do this, but maybe a better way is to (yes, John finally read _that_ part of the man page <smile>) use event_loop() and write my own loop surrounding it, instead of using event_dispatch() with its' own loop? Or maybe I misunderstood the man page (wouldn't be the first time _that_ has happened <shrug>) :-)

Regards,

John

Falling You - exploring the beauty of voice and sound
http://www.fallingyou.com











_______________________________________________
Libevent-users mailing list
Libevent-users@monkey.org
http://monkey.org/mailman/listinfo/libevent-users

Reply via email to