Python Windows Connect via a specific interface -
i'm trying connect host via specific network interface failed. here http://tangentsoft.net/wskfaq/advanced.html in paragraph 4.10 says bind() must call ip interface make connect(). here code:
import socket time import sleep socketlocale= socket.socket(socket.af_inet, socket.sock_stream) socketlocale.setsockopt(socket.sol_socket,socket.so_keepalive,1) socketlocale.settimeout(10) #10.179.51.239 ip address of 1 of network interfaces socketlocale.bind(("10.179.51.239",45365)) #or socketlocale.bind(("10.179.51.239",0)) socketlocale.connect(("stackoverflow.com",80)) sleep(10) socketlocale.close()
the error is: [errno 10049]the requested address not valid in context
Comments
Post a Comment