Created
March 27, 2018 16:33
Star
You must be signed in to star a gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Use the IP_BOUND_IF socket option to bind to a specific network interface on macOS. | |
''' | |
import socket | |
IP_BOUND_IF = 25 | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
s.setsockopt(socket.IPPROTO_IP, IP_BOUND_IF, socket.if_nametoindex('en0')) | |
s.connect(("151.101.193.67" , 80)) | |
s.sendall(b"GET / HTTP/1.1\r\nHost: www.cnn.com\r\n\r\n") | |
print(s.recv(4096)) | |
s.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment