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

[Libevent-users] libevent client tries to reconnect to a lost server



Thanx Sashan for your answer. I did it in the way you pointed out, but the application stops once the evtimer is on : segmentation fault.


Nick, this is how I did it :

1. create the bufferevent with bufferevent_socket_new()
2. set the callback with bufferevent_setcb()
3. enable the bufferevent for READing with bufferevent_enable()
4. connect the bufferevent with bufferevent_socket_connect()

Of course, this is not enough, I introduced an evtimer which becomes active once the bufferevent connection is lost. When the connection is up and running, then the evtimer is removed :

5. create the event timer with evtimer_new(). Its callback creates a new bufferevent and sets it as active and removes the evtimer with evtimer_del().


>
> What I need : a libevent client which tries to reconnect periodically after loosing connection with the server.
>
> To solve this problem I add evtimer that becomes active once the connection with the server is lost. The evtimer callback calls bufferevent_socket_connect(),
> but this function returns a negative value. Why ? How can I solve such a problem ?
>
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.