[Libwebsockets] Using libwebsockets like sockets (with no callback event loop)

Andy Green andy at warmcat.com
Mon Oct 12 15:12:24 CEST 2020

On October 12, 2020 1:47:16 PM GMT+01:00, Mark Easton <mark.easton at ctdi.com> wrote:
>I know "WebSockets" is different from "sockets" but is it possible to
>use the library like a standard socket server/client?

No, lws are nonblocking.  And the event loop lets us do things while we are waiting for data, run many sockets etc.

>For example, once client is connected, you can send and receive data
>without the service callback loop, with simple write() and read()

There is no 'simple' read and write, there's blocking and nonblocking.  Entered a blocking read()?  Want to write something?  Can't unless you introduce multiple threads and locking.

>I have spent many hours searching for an answer but have not managed to
>find one yet.

You should have spent those hours writing event loop based code :-)



More information about the Libwebsockets mailing list