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

[Libevent-users] event_add while running main loop



good morning/evening/afternoon, whatever matches your timezone :-)

i've been scratching my head over one issue for some time and couldn't find 
anything helpful on the net either so here's my last resort i hope.

i have a unix/c program using, surprise, libevent. it runs 3 events, a tcp 
client, a tcp listener and a timer. everything works fine. the problem now is 
that the server to which i connect the tcp client event drops out occasionally. 
because of that i added the timer event to do checks. that works fine, too.
now if i notice that the server is down i want to reconnect without killing the 
event loop so that the listener is not affected. what i do in case of a 
disconnect is close the socket, event_del, event_free. after that i connect the 
socket again and then add the event the same way as i do when the programs 
starts:
evutil_make_socket_nonblocking(so);
client = event_new(base, so, EV_READ|EV_PERSIST, incoming, (void *)base);
event_add(client, NULL);

at this point nothing comes in at all so i tried event_active(client, NULL, 
NULL) which only works for a second or so meaning i get 3 lines and nothing 
after that.
now the big question is is it possible to add an event while the main loop is 
running? and if so what did i miss?


any sort of hints would be very much appreciated :-)


--
ah-consulting.net
Götz T. Fischer CertIT&Comp
Senior Consultant
Phone: +49(0)7225/98 98 79
eMail: g.fischer@xxxxxxxxxxxxxxxxx
http://www.ah-consulting.net
http://www.ah-webhosting.com
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.