axl_bool vortex_connection_reconnect ( VortexConnection connection,
VortexConnectionNew  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 vortex_connection_set_data and vortex_connection_set_data_full functions, the connection reference count and remote profiles read.

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 (! vortex_connection_is_ok (connection, axl_false)) {
4  // connection is not available, try to reconnect.
5  if (! vortex_connection_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
connectionThe connection to reconnect to.
on_connectedOptional handler. This function works as vortex_connection_new. This handler can be defined to notify when the connection has been reconnected.
user_dataUser defined data to be passed to on_connected.
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 vortex_connection_is_ok(), vortex_hash_clear(), vortex_hash_foreach2(), and vortex_thread_pool_new_task().