8000 Multicast Group Join Fails with ValueError from setsockopt() on v1.24.0 · Issue #16100 · micropython/micropython · GitHub
[go: up one dir, main page]

Skip to content

Multicast Group Join Fails with ValueError from setsockopt() on v1.24.0 #16100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
geirp opened this issue Oct 28, 2024 · 1 comment · Fixed by #16121
Closed

Multicast Group Join Fails with ValueError from setsockopt() on v1.24.0 #16100

geirp opened this issue Oct 28, 2024 · 1 comment · Fixed by #16121
Labels

Comments

@geirp
Copy link
geirp commented Oct 28, 2024

Port, board and/or hardware

rp2 port, Raspberry Pi PICO W

MicroPython version

MicroPython v1.24.0 on 2024-10-25; Raspberry Pi Pico W with RP2040

Reproduction

import network
import time
import socket
import struct
import sys

ssid = None
password = None

MCAST_GROUP = '239.3.3.3'
MCAST_PORT = 50007

def inet_aton(ip_str):
    return bytes(map(int, ip_str.split('.')))

wlan = network.WLAN(network.STA_IF)
wlan.active(True)
if ssid:
    wlan.connect(ssid, password)
    while not wlan.isconnected():
        time.sleep(0.25)

sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

mreq = struct.pack("4sL", inet_aton(MCAST_GROUP), 0) 
print ('mreq:', mreq)

try:
    sock.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, mreq)
    print("success")
except Exception as e:
    sys.print_exception(e)
    sys.exit()

while True:
    try:
        print('recv:', sock.recv(1024))
    except Exception as e:
        sys.print_exception(e)
        sys.exit()

Expected behaviour

mreq: b'\xef\x03\x03\x03\x00\x00\x00\x00'
success

Observed behaviour

mreq: b'\xef\x03\x03\x03\x00\x00\x00\x00'
Traceback (most recent call last):
File "<stdin>", line 30, in <module>
ValueError:

Additional Information

This works on v1.23.0 provided wlan is active.

Code of Conduct

Yes, I agree

@dpgeorge
Copy link
Member

Thanks for the clear report. I can confirm the issue. Should be fixed by #16121.

CC22

dpgeorge added a commit to dpgeorge/micropython that referenced this issue Nov 4, 2024
This was missed in 628abf8.  The the bug
was that, when IPv6 is enabled, the `sizeof(ip_addr_t)` is much larger than
IPv4 size, which is what's needed for IGMP addressing.

Fixes issue micropython#16100.

Signed-off-by: Damien George <damien@micropython.org>
dpgeorge added a commit that referenced this issue Nov 28, 2024
This was missed in 628abf8.  The the bug
was that, when IPv6 is enabled, the `sizeof(ip_addr_t)` is much larger than
IPv4 size, which is what's needed for IGMP addressing.

Fixes issue #16100.

Signed-off-by: Damien George <damien@micropython.org>
wiznet-grace pushed a commit to wiznet-grace/micropython that referenced this issue Feb 27, 2025
This was missed in 628abf8.  The the bug
was that, when IPv6 is enabled, the `sizeof(ip_addr_t)` is much larger than
IPv4 size, which is what's needed for IGMP addressing.

Fixes issue micropython#16100.

Signed-off-by: Damien George <damien@micropython.org>
wiznet-grace pushed a commit to WIZnet-ioNIC/WIZnet-ioNIC-micropython that referenced this issue Feb 28, 2025
This was missed in 628abf8.  The the bug
was that, when IPv6 is enabled, the `sizeof(ip_addr_t)` is much larger than
IPv4 size, which is what's needed for IGMP addressing.

Fixes issue micropython#16100.

Signed-off-by: Damien George <damien@micropython.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants
0