I have Python code like the following that makes a TCP connection over Wifi to a Linux microcomputer from my personal laptop. This works when I connected to the Wifi network of the microcomputer from my personal laptop. However, if I'm also connected to another network over ethernet, this does not work.
import socket
PORT = 65432
HOST = "192.168.6.2"
socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # socket creation
socket.connect((HOST, PORT)) # socket connection
To address this problem of being connected to Ethernet: when connecting via ssh, I use the following: ssh -B en0 username@192.168.1.1
. Please see this post for details on the network.
I basically want to to tell the Python socket library to include the -B en0
option, but am not sure how to do this.
source https://stackoverflow.com/questions/76367840/correctly-configure-ip-network-when-using-python-socket-library
Comments
Post a Comment