G gpa Member Licensed User Longtime User Mar 15, 2022 #1 Hi... I have a app running fine on rpi zero 2. It sends data over wlan0 no problems. However - if I connect a local ethernet connection (via usb0) then my app tries to send data that way instead of over wlan0. But that's just a local connection and has no internet access. I altered the route metrics so wlan0 is much lower than usb0 but that didn't fix it. Ideally I'd like to select the interface to use for internet access programatically - is that possible in b4j? Thanks....
Hi... I have a app running fine on rpi zero 2. It sends data over wlan0 no problems. However - if I connect a local ethernet connection (via usb0) then my app tries to send data that way instead of over wlan0. But that's just a local connection and has no internet access. I altered the route metrics so wlan0 is much lower than usb0 but that didn't fix it. Ideally I'd like to select the interface to use for internet access programatically - is that possible in b4j? Thanks....
Erel B4X founder Staff member Licensed User Longtime User Mar 16, 2022 #2 Try this: Code: Copy Dim inet As JavaObject inet.InitializeNewInstance("java.net.InetSocketAddress", Array("ip.address.of.correct.driver", 0)) socket.As(JavaObject).GetFieldJO("socket").RunMethod("bind", Array(inet)) 'socket' should be an initialized and unconnected socket. Upvote 0
Try this: Code: Copy Dim inet As JavaObject inet.InitializeNewInstance("java.net.InetSocketAddress", Array("ip.address.of.correct.driver", 0)) socket.As(JavaObject).GetFieldJO("socket").RunMethod("bind", Array(inet)) 'socket' should be an initialized and unconnected socket.
MicroDrie Well-Known Member Licensed User Longtime User Mar 18, 2022 #4 Not only the metrics are important when choosing a route. If a lower metric is not enough, you can specify a specific interface for the route. With the command route print you can find the number of the preferred interface, for example 2. Then you can add an IF 2 to the default route at the end. example route Code: Copy route CHANGE 192.168.1.0 MASK 255.255.255.0 192.168.1.1 METRIC 2 IF 2 Upvote 0
Not only the metrics are important when choosing a route. If a lower metric is not enough, you can specify a specific interface for the route. With the command route print you can find the number of the preferred interface, for example 2. Then you can add an IF 2 to the default route at the end. example route Code: Copy route CHANGE 192.168.1.0 MASK 255.255.255.0 192.168.1.1 METRIC 2 IF 2