This function allows setting the user timeout for UTCP connections.
meshlink_set_channel_rcvbuf(handle, channel, size);
}
+ /// Set the connection timeout used for channels to the given node.
+ /** This sets the timeout after which unresponsive channels will be reported as closed.
+ * The timeout is set for all current and future channels to the given node.
+ *
+ * @param channel A handle for the channel.
+ * @param timeout The timeout in seconds after which unresponsive channels will be reported as closed.
+ * The default is 60 seconds.
+ */
+ void set_node_channel_timeout(node *node, int timeout) {
+ meshlink_set_node_channel_timeout(handle, node, timeout);
+ }
+
/// Open a reliable stream channel to another node.
/** This function is called whenever a remote node wants to open a channel to the local node.
* The application then has to decide whether to accept or reject this channel.
return utcp_get_recvq(channel->c);
}
+void meshlink_set_node_channel_timeout(meshlink_handle_t *mesh, meshlink_node_t *node, int timeout) {
+ if(!mesh || !node) {
+ meshlink_errno = MESHLINK_EINVAL;
+ return;
+ }
+
+ node_t *n = (node_t *)node;
+
+ pthread_mutex_lock(&mesh->mesh_mutex);
+
+ if(!n->utcp) {
+ n->utcp = utcp_init(channel_accept, channel_pre_accept, channel_send, n);
+ }
+
+ utcp_set_user_timeout(n->utcp, timeout);
+
+ pthread_mutex_unlock(&mesh->mesh_mutex);
+}
+
void update_node_status(meshlink_handle_t *mesh, node_t *n) {
if(n->status.reachable && mesh->channel_accept_cb && !n->utcp) {
n->utcp = utcp_init(channel_accept, channel_pre_accept, channel_send, n);
*/
extern size_t meshlink_channel_get_recvq(struct meshlink_handle *mesh, struct meshlink_channel *channel);
+/// Set the connection timeout used for channels to the given node.
+/** This sets the timeout after which unresponsive channels will be reported as closed.
+ * The timeout is set for all current and future channels to the given node.
+ *
+ * \memberof meshlink_node
+ * @param mesh A handle which represents an instance of MeshLink.
+ * @param channel A handle for the channel.
+ * @param timeout The timeout in seconds after which unresponsive channels will be reported as closed.
+ * The default is 60 seconds.
+ */
+extern void meshlink_set_node_channel_timeout(struct meshlink_handle *mesh, struct meshlink_node *node, int timeout);
+
/// Hint that a hostname may be found at an address
/** This function indicates to meshlink that the given hostname is likely found
* at the given IP address and port.
meshlink_set_error_cb
meshlink_set_invitation_timeout
meshlink_set_log_cb
+meshlink_set_node_channel_timeout
meshlink_set_node_duplicate_cb
meshlink_set_node_pmtu_cb
meshlink_set_node_status_cb