problem getting micropython loopback example working on PiPico and W5500

I am trying to get the loopback example to work on the PiPico (RP2040) with W550 chip using micropython. I am able to setup an nic, and can ping the board. The problem starts when calling the accept() function of a socket. When calling accept(), the script hangs. I am using this version of the micropython firmware: rp2_w5500_20221111_v2.0.0.uf2. Any suggestions on what is wrong?

Here is my code:

import socket
from machine import Pin,SPI
import network
import rp2
import time
from sys import stdin, stdout

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
    startTs = time.time()
    while not nic.isconnected():
        if time.time() - startTs > 5:
    return nic if nic.isconnected() else False

def main():
    nic = w5x00_init()
    if not nic:
        print('Problem connecting to network')
        ip = nic.ifconfig()[0]
        print('IP address: ', ip)

    s = socket.socket() #socket.AF_INET, socket.SOCK_STREAM
    s.bind((ip, 5000))
    conn, addr = s.accept() # hangs on this line
    print("Connect to:", conn, "address:", addr) 
    print("Loopback server Open!")
    while True:
        data = conn.recv(2048)
        if data != 'NULL':

if __name__ == "__main__":

I suspect

s = socket.socket()

must have some arguments, supplied, at least W5500 socket number to open socket interface for?

I tried it with:

socket.AF_INET, socket.SOCK_STREAM

with the same result. The example given by Wiznet does not have any arguments. What arguments should I try?

Can you provide link to the sources you refer to? Is there any documentation for the library/calls provided?

There must be at least indication of the W5500 socket number, W5500 is having 8 of them. In the code I see you set up common registers, I see you open socket, set it to listen on port 5000, but I do no see which W5500 socket you a configuring.

FYI, the Wiznet example code is here - RP2040-HAT-MicroPython/examples/Loopback at main · Wiznet/RP2040-HAT-MicroPython · GitHub

But, I found the problem. In my ignorance, I didn’t understand what the socket.accept function did. After studying python (instead of micropython) documentation, I realized it was waiting for another computer to connect to it. When I did so, the function call returned as expected. I apologize for the newbie mistake.

Also FYI, according to python documentation, s = socket.socket() does default to socket.AF_INET, socket.SOCK_STREAM.