/** * @brief Connect the client to its server * * This function begins the connection process for @p client to its * previously set server. This will return EINA_FALSE immediately if an error occurs. * @param client The client object (NOT #NULL) * @param secure If #EINA_TRUE, TLS will be used in the connection * @return #EINA_TRUE if successful, or #EINA_FALSE on failure */ Eina_Bool azy_client_connect(Azy_Client *client, Eina_Bool secure) { DBG("(client=%p)", client); Ecore_Con_Server *svr; int flags = ECORE_CON_REMOTE_NODELAY; if (!AZY_MAGIC_CHECK(client, AZY_MAGIC_CLIENT)) { AZY_MAGIC_FAIL(client, AZY_MAGIC_CLIENT); return EINA_FALSE; } if ((client->connected) || (!client->addr) || (!client->port)) return EINA_FALSE; client->secure = !!secure; if (secure) flags |= ECORE_CON_USE_MIXED; if (!(svr = ecore_con_server_connect(flags, client->addr, client->port, NULL))) return EINA_FALSE; ecore_con_server_data_set(svr, client); ecore_con_server_timeout_set(svr, 1); client->net = azy_net_new(svr); azy_net_header_set(client->net, "host", NULL); azy_net_header_set(client->net, "host", client->addr); return EINA_TRUE; }
/** * @brief Set a connection timeout on a client * * This function sets a timeout on @p client. After @p timeout seconds * without data being transmitted, the client will automatically disconnect. * @param client The client (NOT NULL) * @param timeout The time, in seconds, to disconnect after */ void azy_client_timeout_set(Azy_Client *client, double timeout) { DBG("(client=%p,timeout=%g)", client, timeout); ecore_con_server_timeout_set(client->net->conn, timeout); }