Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Current »

 Send a WebSocket message.

Files

http-c.h/http-c.c

Prototype

Arguments

p_conn_obj

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

p_msg_obj

Pointer to a valid HTTPc 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

Configuration flags:

HTTPc_FLAG_WEBSOCK_NO_BLOCK

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 previously upgraded to WebSocket to use this function. Refer to the HTTPc_WebSockUpgrade() function. 

    1. The available Message Types are :
      HTTPc_WEBSOCK_MSG_TYPE_TXT_FRAME 
      HTTPc_WEBSOCK_MSG_TYPE_BIN_FRAME
      HTTPc_WEBSOCK_MSG_TYPE_CLOSE 
      HTTPc_WEBSOCK_MSG_TYPE_PING
      HTTPc_WEBSOCK_MSG_TYPE_PONG 

  2. Payload Content:

    1. The "Payload data" (argument p_data) is defined as "Extension data" concatenated with "Application data". 

    2. Extension data length is 0 Bytes unless an extension has been negotiated during the handshake. 

    3. "Extension data" content and length are defines by the extension negotiated.  If negotiated, the "Extension data" must be handled by the Application. 

  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 message 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. Client-to-Server Masking 

    1. According to the RFC 6455 section 5.2: "All frames sent from the client to the server are masked by a 32-bit value that is contained within the frame." 

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

 

 

  • No labels