Skip to content

multicast and broadcast #1652

Jul 30, 2022 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

You have to correctly configure your socket interface to provide those frames and IP datagrams for you. It depends on your OS/environment.
For Linux/Win32, check here (no relation to them).
On Linux, something like this will call your fn with MG_EV_READ on every multicast UDP from the SSDP/UPnP group:

int main(void) {
  struct mg_mgr mgr;
  static struct mg_connection *c;
  struct ip_mreq mreq;

  mg_mgr_init(&mgr);
  c = mg_listen(&mgr, "udp://0.0.0.0:1900", fn, NULL);
  mreq.imr_multiaddr.s_addr = inet_addr("239.255.255.250");
  mreq.imr_interface.s_addr = htonl(INADDR_ANY);
  if (setsockopt((int) c->fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char *) &mreq,
                 sizeof(mreq)) < 0) …

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@lightyear67
Comment options

@cpq
Comment options

Answer selected by scaprile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #1651 on July 30, 2022 17:57.