0

I'm developing a simple websocket server using the libwebsockets library on Linux machine.
I'd like to send to client just connected a command.
If I use lws_write I receive a back-to-back error, as reported from the manual.
If I use lws_callback_on_writable() nothing is sent.
The code is the following:

case LWS_CALLBACK_ESTABLISHED:
    lwsl_user("LWS_ESTABL\n");
    /* add ourselves to the list of live pss held in the vhd */
    lws_ll_fwd_insert(pss, pss_list, vhd->pss_list);

    pss->wsi = wsi;
    pss->last = vhd->current;

    // Send init request to client
    lwsl_user("Sending init to client ..\n");

    vhd->amsg.payload = malloc(LWS_PRE + 4);
    char *p= ((char*)vhd->amsg.payload)+LWS_PRE;
    memcpy( p, "init", 4);
    vhd->amsg.len = 4;

    //lws_write(wsi, p, 4, LWS_WRITE_TEXT);
    lws_callback_on_writable((*pss).wsi);
    break;

Any idea?

Priya
  • 334
  • 3
  • 8
SteMMo
  • 392
  • 1
  • 4
  • 23

0 Answers0