Bind with Ethernet Port Only
-
- Posts: 2
- Joined: Mon Sep 28, 2020 6:16 pm
Bind with Ethernet Port Only
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.
- MostlyHarmless
- Posts: 166
- Joined: Thu Nov 21, 2019 6:25 pm
- Location: Pennsylvania, USA
Re: Bind with Ethernet Port Only
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
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