int nopoll_conn_send_binary ( noPollConn conn,
const char *  content,
long  length 

Allows to send a binary (op code 2) message over the provided connection with the provided length.

connThe connection where the message will be sent.
contentThe content to be sent (it should be utf-8 content or the function will fail).
lengthAmount of bytes to take from the content to be sent. Note you cannot pass in -1 (unlike nopoll_conn_send_text).
The number of bytes written otherwise < 0 is returned in case of failure. The function will fail if some parameter is NULL or undefined. In the case of failure, also check errno variable to know more what went wrong.

See 2.1. Retrying failed write operations to know more about error codes and when it is possible to retry write operations.

The function returns the number of bytes sent, being the max amount of bytes that can be reported as sent by this funciton. This means value reported by this function do not includes headers. The funciton also returns the following general indications:

N : number of bytes sent (user land bytes sent, without including web socket headers). 0 : no bytes sent (see errno indication). See also nopoll_conn_complete_pending_write -1 : failure found -2 : retry operation needed (NOPOLL_EWOULDBLOCK)

References NOPOLL_BINARY_FRAME, and nopoll_true.