axl_bool myqtt_conn_reconnect ( MyQttConn connection,
MyQttConnNew  on_connected,
axlPointer  user_data 
)

Allows to reconnect the given connection, using actual connection settings.

Given a connection that is actually broken, this function can be used to reconnect it trying to find, on the same host and port, the peer that the connection was linked to.

The connection "reconnected" will keep the connection identifier, any data set on this connection using the myqtt_conn_set_data and myqtt_conn_set_data_full functions, the connection reference count....

If the function detect that the given connection is currently working and connected then the function does nothing.

Here is an example:

1 // check if the connection is broken, maybe remote site have
2 // failed.
3 if (! myqtt_conn_is_ok (connection, axl_false)) {
4  // connection is not available, try to reconnect.
5  if (! myqtt_conn_reconnect (connection,
6  // no async notify
7  NULL,
8  // no user data
9  NULL)) {
10  printf ("Link failure detected..");
11  }else {
12  printf ("Unable to reconnect to remote site..");
13  }
14 } // end if
Parameters
connectionThe connection to reconnect to.
on_connectedOptional handler. This function works as myqtt_conn_new. This handler can be defined to notify when the connection has been reconnected.
user_dataUser defined data to be passed to on_connected.
Returns
axl_true if the connection was successfully reconnected or axl_false if not. If the on_connected handler is defined, this function will always return axl_true.

References myqtt_conn_is_ok(), and myqtt_thread_pool_new_task().