[Libwebsockets] lws server that needs to do a client GET

Steve Calfee stevecalfee at gmail.com
Thu Jul 26 19:08:58 CEST 2018


On Tue, Jul 24, 2018 at 11:44 PM, Chropin Hu <chropinhu at gmail.com> wrote:
> I think, it dependent on your requirments.
> One context can serve a lot of client, but If the websocket server do a lot
> of data transfer,
> for example dash server, may be you need a multi-thread enabled server,
> you can reference to
> https://github.com/warmcat/libwebsockets/tree/master/minimal-examples/ws-server/minimal-ws-server-threads
>
>
> On Wed, Jul 25, 2018 at 12:13 PM, Steve Calfee <stevecalfee at gmail.com>
> wrote:
>>
>> Hi,
>>
>> My webserver needs to do client activity (my server wants to start
>> several client GETs (like after getting a POST connection). Do I need
>> to create another context for each client?
>>
>> lws_client_connect_info contains a pointer to
>> struct lws_context *context;    /**< lws context to create connection in
>> */
>>
>> I tried just using my server context and the client access seems to
>> work, but is it the proper way?
>>
>> It seems like not, would using only one context work?
>>
>> What do I do special running the contexts if I have 3 clients running
>> and one http server using running lws_service?
>>
>> Thanks, Steve
>> _______________________________________________

Let me try to be clearer. I have small embedded linux systems that run
webservers connected by wifi. When any system gets a command via a
http get/post call it then sends the command on to all the other
interconnected embedded systems. So all systems are both a host and
use a client. The number of systems is quite small, I would be
surprised if there was ever more than 10 - so no need for threads.

This question is solely about the context passed around in the client
info structure and used in lws_client_connect_via_info. Traditionally
a context used in a library is private data used by the library. Is
libwebsockets happy with the same context being used for say 10
simultaneous, asynchronous client connections?

Thanks, Steve



More information about the Libwebsockets mailing list