<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[LAN W5500 socket listening does not work]]></title><description><![CDATA[<p dir="auto">Hi friends</p>
<p dir="auto">I have written a simply micropython test program as a web server.<br />
It works when I am using the configured ip address of wifi connection (ip via dhcp).<br />
Then I have tried the LAN base module W5500 V12.<br />
Unfortunately it does not work with the configured ip address of the ethernet module (ip via dhcp) .</p>
<p dir="auto">I have used....<br />
lan = module.get(module.LANBASE)<br />
...instead of...<br />
lan = network.LAN(mdc=23, mdio=18, power=21, phy_type=network.PHY_W5500, phy_addr=0)<br />
lan.active(True)<br />
...because I get an error message that network does not support LAN methode.</p>
<p dir="auto"><strong>Here is my micropython example code:</strong></p>
<p dir="auto">from m5stack import *<br />
from m5ui import *<br />
from uiflow import *<br />
import wifiCfg<br />
import network<br />
import socket<br />
import module</p>
<p dir="auto">#WiFi<br />
wifiCfg.screenShow()<br />
wifiCfg.autoConnect(lcdShow=True)<br />
wifiIp = wifiCfg.wlan_sta.ifconfig()[0]<br />
title0 = M5Title(title="SERVER-EXAMPLE", x=95, fgcolor=0xFFFFFF, bgcolor=0xff001d)<br />
label0 = M5TextBox(10, 40, "WiFi ip :" + str(wifiIp), lcd.FONT_Ubuntu, 0xfff500, rotate=0)</p>
<p dir="auto">#Ethernet<br />
lan = module.get(module.LANBASE)<br />
#lan = network.LAN(mdc=23, mdio=18, power=21, phy_type=network.PHY_W5500, phy_addr=0)<br />
#lan.active(True)<br />
eth0Ip = lan.get_if_config()[0]<br />
label1 = M5TextBox(10, 60, "Eth0 ip :" + str(eth0Ip), lcd.FONT_Ubuntu, 0xfff500, rotate=0)</p>
<p dir="auto">#Choose ip address<br />
ip = wifiIp # works<br />
#ip = eth0Ip # does not work</p>
<p dir="auto">#Socket binding<br />
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)<br />
sock.bind((ip, 80))</p>
<p dir="auto">label2 = M5TextBox(10, 80, "SERVER running at " + ip, lcd.FONT_Ubuntu, 0xfff500, rotate=0)</p>
<p dir="auto">#Listening<br />
sock.listen(1)<br />
while True:<br />
conn, addr = sock.accept()<br />
print('Connection from:', addr)<br />
conn.sendall('Hello, world!')<br />
conn.close()</p>
]]></description><link>https://community.m5stack.com/topic/5061/lan-w5500-socket-listening-does-not-work</link><generator>RSS for Node</generator><lastBuildDate>Tue, 28 Apr 2026 16:26:18 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/5061.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 17 Feb 2023 07:32:07 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to LAN W5500 socket listening does not work on Wed, 03 Jan 2024 22:16:07 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/m5stickfreakler" aria-label="Profile: m5stickfreakler">@<bdi>m5stickfreakler</bdi></a> hi - did you ever solve this?  I am having the same problem with both the LAN Module and the LAN Base - it initialises the LAN, gets an IP address, but just won't accept data from a browser when I try the following code:<br />
s = socket.socket()<br />
s.bind(('172.17.15.87',80))<br />
s.listen(1)</p>
<p dir="auto">I would love to get this sorted!</p>
<p dir="auto">Cheers,</p>
]]></description><link>https://community.m5stack.com/post/23219</link><guid isPermaLink="true">https://community.m5stack.com/post/23219</guid><dc:creator><![CDATA[Treadbrook]]></dc:creator><pubDate>Wed, 03 Jan 2024 22:16:07 GMT</pubDate></item><item><title><![CDATA[Reply to LAN W5500 socket listening does not work on Fri, 17 Feb 2023 16:30:07 GMT]]></title><description><![CDATA[<p dir="auto"><strong>tried with modified code, but no luck:</strong></p>
<p dir="auto">from m5stack import *<br />
from m5ui import *<br />
from uiflow import *<br />
import wifiCfg<br />
import network<br />
import socket<br />
import module</p>
<p dir="auto">#WiFi<br />
wifiCfg.screenShow()<br />
wifiCfg.autoConnect(lcdShow=True)<br />
wifiIp = wifiCfg.wlan_sta.ifconfig()[0]<br />
title0 = M5Title(title="SERVER-EXAMPLE", x=95, fgcolor=0xFFFFFF, bgcolor=0xff001d)<br />
label0 = M5TextBox(10, 40, "WiFi ip :" + str(wifiIp), lcd.FONT_Ubuntu, 0xfff500, rotate=0)</p>
<p dir="auto">counter = 0</p>
<p dir="auto">#Ethernet<br />
lan = module.get(module.LANBASE)<br />
eth0Ip = lan.get_if_config()[0]<br />
label1 = M5TextBox(10, 60, "Eth0 ip :" + str(eth0Ip), lcd.FONT_Ubuntu, 0xfff500, rotate=0)<br />
lan.tcp_udp_config(eth0Ip, 80, 1, 1) ## es muss ein call gemacht werden, damit das Programm weiter läuft</p>
<p dir="auto">#Choose ip address<br />
#ip = wifiIp # works<br />
ip = eth0Ip # does not work</p>
<p dir="auto">label2 = M5TextBox(10, 80, "SERVER is running", lcd.FONT_Ubuntu, 0xfff500, rotate=0)</p>
<p dir="auto">label3 = M5TextBox(10, 100, "waiting...", lcd.FONT_Ubuntu, 0xfff500, rotate=0)<br />
label4 = M5TextBox(10, 120, "received?", lcd.FONT_Ubuntu, 0xfff500, rotate=0)</p>
<p dir="auto">if ip == wifiIp:</p>
<pre><code>server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
server.settimeout(30)
server.bind((wifiIp, 80))

while True:
    server.listen(1)
    
    (conn, addr) = server.accept()
    request = conn.recv(4096)

    if request:
        counter = counter + 1
        request = str(request)
        conn, addr = server.accept()
        label3.setText(str(counter))
        label4.setText(str(request))
        response = 'Hello, world!'
        conn.sendall(response)
        conn.close()

    wait_ms(2)
</code></pre>
<p dir="auto">if ip == eth0Ip:</p>
<pre><code>while True:
    if lan.is_available_packet(1):
        counter = counter + 1
        request = str(lan.tcp_receive_packet(0))
        label3.setText(str(counter))
        label4.setText(str(request))
        response = 'Hello, world!'
        lan.tcp_send_packet(response)

    wait_ms(2)
</code></pre>
]]></description><link>https://community.m5stack.com/post/20117</link><guid isPermaLink="true">https://community.m5stack.com/post/20117</guid><dc:creator><![CDATA[M5StickFreakler]]></dc:creator><pubDate>Fri, 17 Feb 2023 16:30:07 GMT</pubDate></item><item><title><![CDATA[Reply to LAN W5500 socket listening does not work on Fri, 17 Feb 2023 15:55:39 GMT]]></title><description><![CDATA[<p dir="auto">Hi felmue<br />
Thanks for your appreciated reply.<br />
Unfortunately it is unusable for me in that way. I would like to bind the ip address to a socket on port 80 (http server). And I dont want that the application is blocked until a client connects.<br />
best regards</p>
]]></description><link>https://community.m5stack.com/post/20116</link><guid isPermaLink="true">https://community.m5stack.com/post/20116</guid><dc:creator><![CDATA[M5StickFreakler]]></dc:creator><pubDate>Fri, 17 Feb 2023 15:55:39 GMT</pubDate></item><item><title><![CDATA[Reply to LAN W5500 socket listening does not work on Fri, 17 Feb 2023 13:31:39 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="plugin-mentions-user plugin-mentions-a" href="/user/m5stickfreakler" aria-label="Profile: M5StickFreakler">@<bdi>M5StickFreakler</bdi></a></p>
<p dir="auto">have you tried the <a href="https://flow.m5stack.com/?examples=lan_tcp_server_demo" target="_blank" rel="noopener noreferrer nofollow ugc">example</a>? It works for me.</p>
<p dir="auto">Note: the <code>Init LAN</code> block blocks until a client connects.</p>
<p dir="auto">Thanks<br />
Felix</p>
]]></description><link>https://community.m5stack.com/post/20113</link><guid isPermaLink="true">https://community.m5stack.com/post/20113</guid><dc:creator><![CDATA[felmue]]></dc:creator><pubDate>Fri, 17 Feb 2023 13:31:39 GMT</pubDate></item></channel></rss>