i'd like to ask how to bind sockets properly. I have problem with binding socket to Ethernet modul W5500 for arduino and listening raw packets.I cant understand why i am getting error with binding. During compilation, binding returns OSError: [Errno 5] EIO. My code is:
from machine import Pin,SPI
import network
import time
import lwip
#W5x00 chip init
def w5x00_init():
spi = SPI(0,2_000_000, mosi=Pin(19),miso=Pin(16),sck=Pin(18))
nic = network.WIZNET5K(spi,Pin(17),Pin(20)) #spi,cs,reset pin
nic.active(True)
nic.ifconfig(('192.168.0.1','255.255.255.0','',''))
print(nic.ifconfig())
return nic
def main():
nic = w5x00_init()
s = lwip.socket(lwip.AF_INET,lwip.SOCK_RAW,lwip.IPPROTO_IP)
s.bind(("192.168.0.1",0))
# s.listen(5)
while(1):
# conn, addr = s.accept()
#data, addr = s.recvfrom(1508)
time.sleep(1)
if __name__ == "__main__":
main()
I wanted to bind ip of ethernet to socket and receive coming raw packets
type here