sstaub / Ethernet3

Ethernet library for Arduino and Ethernetshield2 / WIZ550io / WIZ850io / USR-ES1 with Wiznet W5500 chip
Other
76 stars 34 forks source link

MAX_SOCK_NUM 8 in w5500.h #24

Closed putzlicht closed 5 years ago

putzlicht commented 5 years ago

Hi :)

I am not sure, may be its a bug in my code. But i guess there is a problem with the "MAX_SOCK_NUM 8" definition in w5500.h In my case socket 1 is doing some UDP. On socket 2 a webserver is running. So i init the w5500 with Ethernet.init(2); The webpage uses some javascript to get new values from the server. But when the controller (in my case a Teensy 3.6) restarts with a cold reset and the html page is already loaded, the javascript function gets no connection to the server. But after refreshing the page manually in the browser 6 times the js-function was fine. So i took a look at all socket status registers with w5500.readSnSR() during the manual webpage refreshing. And after each refresh a new socket was used from socket 3 to socket 8. Changing MAX_SOCK_NUM from 8 to 2 in w5500.h solved this for me.

Best Putzlicht

sstaub commented 5 years ago

Did you have the same problem with the original Teensy library? The problem is that there is no elegant way to convert MAX_SOCK_NUM in a normal variable which is controlled by the init function. Did you tried Ethernet.init(4) or did you need the extended memory? Personal I never worked with TCP but on conventional applications, when a TCP connection is established, a new socket will be opened.