← index #8729Issue #10872
Off-topic · high · value 1.739
QUERY · ISSUE

socket.SO_BROADCAST

openby JarynCodeopened 2022-06-06updated 2023-06-19
bug

Use socket.SO_BROADCAST to WOL, but get "AttributeError: 'module' object has no attribute 'SO_BROADCAST'".how to fix it?

CANDIDATE · ISSUE

AttributeError: 'module' object has no attribute 'sockaddr'

openby klint-kopened 2023-02-27updated 2023-02-27
bug

As not seen in the code the connection works. When the Error happens is when the webpage is to be loaded.

Version:
MicroPython v1.19.1-896-g2e4dda3c2 on 2023-02-25; Raspberry Pi Pico W with RP2040

Error:
File "/lib/socket.py", line 47, in accept
AttributeError: 'module' object has no attribute 'sockaddr'

Code:

import socket
from do_connect import * #  to do the connection
from test_ssid import * # to check if the ssid is there

if test_ssid:
    do_connect()
    
with open("index.html", "r") as page:
    html = page.read()

addr = socket.getaddrinfo('0.0.0.0', 80)[0][-1]
s = socket.socket()
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind(addr)
s.listen(1)

while True:
    cl, addr = s.accept()
   ...

Code from socket:

43  class socket(_socket.socket):
44  
45      def accept(self):
46          s, addr = super().accept()
**47          addr = _socket.sockaddr(addr)**
48          return (s, (_socket.inet_ntop(addr[0], addr[1]), addr[2]))

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied