[Libwebsockets] LWS_CALLBACK_HTTP send/write text only

Peter Kroon plakroon at gmail.com
Wed Apr 8 13:22:36 CEST 2015


For some reason I'm not getting any emails send to the list. Checked
settings, look OK.
I've read your reply on:
http://ml.libwebsockets.org/pipermail/libwebsockets/2015-April/thread.html

>How about it is working properly, but the browser is waiting for some
legit http / html to appear befoe rendering it?  When the socket closes he
gives up.
>For example it should be saying "200 OK\r\n"...

I've tried it with:
the_response = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\nHello,
World!"; and the result is the same.
Do you have any other suggestions?

Regards,
Peter


2015-04-07 19:49 GMT+02:00 Peter Kroon <plakroon at gmail.com>:

> Hi,
>
> I'm trying to create a http server that will send some text to all
> requests.
> I''ve used the code below. Only when I do Ctrl-C the webserver is shutdown
> and the text will appear on the page in the webbrowser. Any hints on how I
> can make this work properly?
>
>
> case LWS_CALLBACK_HTTP: {
>   char the_response[] = "Hello, World!";
>   int strl = strlen(the_response);
>   int n = libwebsocket_write(wsi, the_response, strl, LWS_WRITE_HTTP);
>   printf("writing hello world ?....%d\n", n);
> }
>
>
> Thanks,
> Peter
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://libwebsockets.org/pipermail/libwebsockets/attachments/20150408/eeaba91d/attachment-0001.html>


More information about the Libwebsockets mailing list