title: Can Python select what network adapter when opening a socket?
body: <p>The target machine running the python application will have three network interfaces available to it.  In general all three networks will be vastly different, however there is a possibility that two of the three could be on similar networks. </p>
  
  <p>In the example below I do not have control over the destination address on ETH 2 (as it a pre-configured system), so I forced into selecting what adapter to use programmaticly. </p>
  
  <p>I am fairly sure that this will fall on how the OS works with routing the connections.  My hope is that there will be a platform independent way to solve the issue using python, because there is a possibility that this application will need to run on Windows 7 as well as a Linux machine.</p>
  
  <p><strong>Example Code</strong>   </p>
  
  <pre><code>import socket
  s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  s.connect(('192.168.0.2', 8000)) # Which device will this connect to??
  </code></pre>
  
  <p><strong>Normal Case</strong>  </p>
  
  <ul>
  <li>ETH 0 Source: 192.168.0.1</li>
  <li>ETH 0 Destination: 192.168.0.2</li>
  <li>ETH 1 Source: 10.20.30.1</li>
  <li>ETH 1 Destination: 10.20.30.2</li>
  <li>ETH 2 Source: 60.50.40.1</li>
  <li>ETH 2 Destination: 60.50.40.1</li>
  </ul>
  
  <p><strong>Possible Trouble Case</strong>  </p>
  
  <ul>
  <li>ETH 0 Source: 192.168.0.1</li>
  <li>ETH 0 Destination: 192.168.0.2</li>
  <li>ETH 1 Source: 10.20.30.1</li>
  <li>ETH 1 Destination: 10.20.30.2</li>
  <li>ETH 2 Source: 192.168.0.3</li>
  <li>ETH 2 Destination: 192.168.0.2</li>
  </ul>
  
  <p><strong>Additional Information</strong><br>
  Adapters ETH0,1,and 2 are all connected to different physical netoworks</p>