[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[Libevent-users] Need help with server

Hi to all.

I tryed to write server with handling events with using event_base_dispatch() in one case and event_base_loop() in another.

In first case event_base_dispatch() called by main thread and in another thread's i process received events (associated with connected clients) with some server logic and send response to client by bufferevent_write(). When all client's disconnect event_base_dispatch() returned. Ok, this case described in documentation.
But i want save server alive state.

And than i try second case: call event_base_loop() in somth like while(_work) cycle. It's calling, all right, but new events (after client's disconnect) not registered. I mean, no new callbacks are not called, but client try to connect with server. OK , let's google it.

Last case: use libevent-2.1.3-alpha's function event_base_loop() with flag EVLOOP_NO_EXIT_ON_EMPTY. Nice, server started to work as i want. But. Client don't receive data from server. I used tcp sniffer, and saw how data transfered in socket, but client (with event_base_loop() realization) not received data (no callback).

Maybe there is some best practice with libevent to create tcp-server? I googled, but most simple realization used event_base_dispatch(), which returned, when last client disconnected.
Would be very grateful for the help

To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.