[Libwebsockets] [Question] Does libwebsockets support sending and receiving multicast packets?

andy at warmcat.com andy at warmcat.com
Wed Jun 24 05:33:10 CEST 2020

On June 24, 2020 3:04:40 AM UTC, "谭小俊(Xiaojun Tan)" <tanxiaojun at oppo.com> wrote:
>Hi, all,
>Sorry to bother you.
>I recently started using libwebsockets for sending and receiving
>network packets.
>But when I plan to use it to send and receive UDP multicast packets, I
>don't know how to do it. I also did not find corresponding tips from
>any documents and examples.


>And there is no corresponding code in the source code, so I want to ask
>whether it supports sending and receiving multicast packets. If not,
>can I manually join the multicast group through the corresponding
>sockfd in libwebsockets (using setsockopt).

Multicast groups is a long way away from lws original focus only on tcp based protocols.  But lws is slowly spreading out there, eg, it comes with dhcp client, ntp client and async dns resolver now all of which are UDP.

I didn't get a chance to complete it yet but there is also a generic lws mDNS client / server patch out of tree that is of course multicast... afaik mDNS is the only common use for multicasting.  There, it wraps the multicasting C apis in mDNS semantics and exposes only mDNS apis.  The mDNS implementation is part of lws rather than user code but unless there's another use for multicast I didn't think about, the general plan is eventually provide mDNS rather than provide wrappers for standard multicast apis.  As you say you can just use the standard C multicast apis on the socketfd.


>This e-mail and its attachments contain confidential information from
>OPPO, which is intended only for the person or entity whose address is
>listed above. Any use of the information contained herein in any way
>(including, but not limited to, total or partial disclosure,
>reproduction, or dissemination) by persons other than the intended
>recipient(s) is prohibited. If you receive this e-mail in error, please
>notify the sender by phone or email immediately and delete it!

More information about the Libwebsockets mailing list