Page 1 of 1

Bind with Ethernet Port Only

Posted: Tue Sep 29, 2020 7:54 am
by samajkapoor
In my project I have both a Wifi Connection and an Ethernet Connection. Is it possible to bind the webserver only to the ethernet interface? Currently I can make requests on both the WiFi and the Ethernet Interface.

Re: Bind with Ethernet Port Only

Posted: Fri Oct 30, 2020 3:58 am
by MostlyHarmless
The usocket module perfectly supports bind((<IP>, <PORT>)). When using '0.0.0.0' (AKA INADDR_ANY) for IP, the server socket will accept connections on all active interfaces. To limit it to one specific interface you should obtain that IP address via WLAN.ifconfig() and use it in the bind() call.

You haven't told us which webserver you are using. For picoweb you would specify that address in the run() call for the app.


Hope this helps, Jan