[Libwebsockets] help regarding Built-in service loop entry loop.

이성훈(Sunghoon Lee) sh1559.lee at hanwha.com
Thu Nov 21 12:46:17 CET 2019


My name is Alex Lee.
Current my streaming server is using direct Linux socket API such as (socket, bind, listen, poll, accept, read/write)

My streaming server receives connection request from several clients and send streaming data back to those requested clients.
The streaming server normally does below routine.

1)      socket(AF_UNIX, SOCK_STREAM, 0);   (Create a server socket)

2)      bind(serverSocket, (struct sockaddr*), .)

3)      listen()

4)      poll()

5)      accept()

6)      read()/write() for the accept client connections

I'd like to convert above routines using build-in service loop entry provided in libwebsocket.
I've read some of libwebsocket's API usage documents and ran examples in my Ubuntu machine.

I'd like to get a confirmation before I start migration to libwebsocket whether my approach is correct or not.
I'd like to use lws's internal built-in service loop entry.
What I'll do is as below.

1.       I'll make static struct lws_protocols protocols[] which has my_callback_http as an lws_context_creation_info's protocols field.
2.       I'll NOT call any linux socket related APIs such as socket, bind, listen, poll, accept, read, write directly.
Instead, I'll just let lws_service api handle all socket related functionalities just like many examples do and will receive event and data through my_callback_http registered in context.
3.       I believe that my_callback_http will get called for client connections and receive requests from clients.
Then I'll send binary streaming data using lws_write instead of using socket API such as accept, read, write and etc.
4.       I am not thinking to use LWS_WITH_EXTERNAL_POLL because I am not running another sever.

Please confirm if my approach above is correct.
If wrong, please correct me.

Thank you for guide and the help!.

Best Regards,

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://libwebsockets.org/pipermail/libwebsockets/attachments/20191121/df904e27/attachment.htm>

More information about the Libwebsockets mailing list