HTTPc_WebSockSend()

Sends a HTTP Request to a remote HTTP server.

Files

http-c.h/http-c.c

Prototype

Arguments

p_conn_obj

Pointer to valid HTTPc Connection upgraded to WebSocket.

p_msg_obj

Pointer to a valid WebSocket message object.

msg_type

Type of message to send.

p_data

Pointer to the payload to send.

data_len

Length of the payload to send.

flags
p_err

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

    HTTPc_ERR_NONE 
HTTPc_ERR_INIT_NOT_COMPLETED
HTTPc_ERR_NULL_PTR
HTTPc_ERR_FEATURE_DIS
HTTPc_ERR_WEBSOCK_INVALID_CONN
HTTPc_ERR_WEBSOCK_INVALID_TX_PARAM
HTTPc_ERR_WEBSOCK_MSG_IS_USED
HTTPc_ERR_MSG_Q_FULL
HTTPc_ERR_MSG_Q_SIGNAL_FAULT
HTTPc_ERR_CONN_SIGNAL_CREATE
HTTPc_ERR_CONN_SIGNAL_TIMEOUT
HTTPc_ERR_CONN_SIGNAL_FAULT
HTTPc_ERR_CONN_SIGNAL_DEL

Returned Values

DEF_OK, 

      if the operation is successful.

DEF_FAIL,

      if the operation has failed.

Required Configuration

None.

Notes / Warnings

  1. The connection object p_conn MUST has been upgraded to WebSocket to use this function. Refer to the HTTPc_WebSockUpgrade() function.

  2. The available Message Types are :

    HTTPc_WEBSOCK_MSG_TYPE_TXT_FRAME (Data msg)
    HTTPc_WEBSOCK_MSG_TYPE_BIN_FRAME (Data msg)
    HTTPc_WEBSOCK_MSG_TYPE_CLOSE (Ctrl msg)
    HTTPc_WEBSOCK_MSG_TYPE_PING (Ctrl msg)
    HTTPc_WEBSOCK_MSG_TYPE_PONG (Ctrl msg)
  3. Data message Restrictions: 

    1. Even if the RFC6455 allow to sent message payload up to 2^64 bytes, only 2^32 bytes is allowed in the current implementation.

  4. Control sessage Restrictions:

    1.  According to the RFC 6455 section 5.5: "All control frames MUST have a payload length of 125 bytes or less and MUST NOT be fragmented.

    2. Close frame have a specific payload format. Refer to the HTTPc_WebSockFmtCloseMsg() function for more information.

  5. The "Payload data" (argument p_data) is defined as "Extension data" concatenated with "Application data". "Extension data" length is 0 Bytes unless an extension has been negotiated during the handshake. "Extension data" content and length are defines by the extension negotiated. If negotiated, the "Extension data" must be handled by the Application.

  6.  The Application DO NOT need to mask the payload since it's handled by the WebSocket module.

  7.  Fragmented message transmission is not currently supported by the current WebSocket implementation.