[Libwebsockets] multiple clients

Joel Winarske joel.winarske at gmail.com
Fri Apr 7 01:30:59 CEST 2017


Would I end up with a unique 'pss' struct for each wsi (parent and child)
in the case of http client?

How do I get the user pointer for a given wsi within a plugin?  I'm
thinking I want to only store state in the parent wsi 'pss' struct, and
then access member variables from it during http client (child) callbacks.

On Thu, Apr 6, 2017 at 4:08 PM, Andy Green <andy at warmcat.com> wrote:

>
>
> On April 7, 2017 6:58:53 AM GMT+08:00, Joel Winarske <
> joel.winarske at gmail.com> wrote:
> >Multiple http client instances via lws_client_connect_via_info().
> >
> >Where can I find a good example of using the "user" pointer in
> >callbacks?
>
> If you're being the server, eg
>
> https://github.com/warmcat/libwebsockets/blob/master/
> plugins/protocol_dumb_increment.c
>
> Client is the same way... set the size of the user allocation in the
> protocols[] struct and then cast user to a per-client 'pss' struct.  Each
> wsi gets his own private pss for as long as he is associated with the
> protocol.
>
> -Andy
>
> >
> >On Thu, Apr 6, 2017 at 3:43 PM, Andy Green <andy at warmcat.com> wrote:
> >
> >>
> >>
> >> On April 7, 2017 2:46:44 AM GMT+08:00, Joel Winarske <
> >> joel.winarske at gmail.com> wrote:
> >> >Hi Andy,
> >> >
> >> >Is there anything preventing simultaneous http clients, or can there
> >> >only
> >> >be one at a time?
> >>
> >> What does 'clients' mean here?  You are being the server and the
> >clients
> >> are remote guys connecting to you?  Or they are your outgoing
> >connections?
> >> Either way:
> >>
> >> No, you can have as many clients as you have sockets available.
> >>
> >> >In my case I'm seeing two stomp on each other, but I'm figuring it's
> >my
> >> >code; thought I would ask!
> >>
> >> They won't 'stomp on each other' (no better characterization also
> >suggests
> >> it's user code) in lws.  But your user code has to be appropriate, if
> >you
> >> point all clients at the same filescope static vars, naturally you
> >will
> >> have problems with vars being overwritten.  Look at how the plugin
> >type
> >> code manages a vhd for the vhost and a pss per connection.
> >>
> >> -Andy
> >>
> >> >
> >> >Thanks,
> >> >Joel
> >>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://libwebsockets.org/pipermail/libwebsockets/attachments/20170406/27e29519/attachment-0002.html>


More information about the Libwebsockets mailing list