HTTPc_ConnOpen

Open an new HTTP connection and connect to the remote HTTP server.

Files

http-c.h/http-c.c

Prototype

CPU_BOOLEAN  HTTPc_ConnOpen (HTTPc_CONN_OBJ  *p_conn_obj,
                             CPU_CHAR        *p_buf,
                             CPU_INT16U       buf_len,
                             CPU_CHAR        *p_hostname_str,
                             CPU_INT16U       hostname_str_len,
                             HTTPc_FLAGS      flags,
                             HTTPc_ERR       *p_err);

Arguments

p_conn_obj

Pointer to the HTTPc Connection Object for which to open the socket.

p_buf

Pointer to the HTTP buffer that will be used to transmit and receive data.

buf_len

Length of the HTTP buffer.

p_hostname_str

Pointer to the hostname (or IP address) string.

hostname_str_len

Length of the hostname (or IP address) string.

flags

Configuration flags:

HTTPc_FLAG_CONN_NO_BLOCK

p_err

Pointer to variable that will receive the return error code from this function:

HTTPc_ERR_NONE
HTTPc_ERR_NULL_PTR
HTTPc_ERR_INIT_NOT_COMPLETED
HTTPc_ERR_CONN_IS_USED
HTTPc_ERR_PARAM_INVALID

HTTPc_ERR_FEATURE_DIS

Returned Values

None.

Required Configuration

None.

Notes / Warnings

  • This function MUST be called after the µCHTTP-client Suite Initialization has been completed.

  • If the µC/HTTP-client Asynchronous Task is enabled (HTTPc_CFG_MODE_ASYNC_TASK_EN macro in http-c_cfg.h), the HTTPc Connection Object will be added to the connection open's queue.  

  • If the HTTPc_FLAG_CONN_NO_BLOCK flag is set, the function will be in non-blocking mode. Therefore, the function could return before the connection opening is finished. For the application to be notified when the opening process completes, the callback function must have been setup before with the parameter type HTTPc_PARAM_TYPE_CONN_CONNECT_CALLBACK