I want to use socket.create_connection()
to set a source address in a ping implementation in python.
But how can I then set the type and the protocol? Because, before, I did:
icmp = socket.getprotobyname("icmp")
my_socket = socket.socket(socket.AF_INET, socket.SOCK_RAW, icmp)
But now, I do:
src_addr = socket.gethostbyname(src_addr)
dest_addr = socket.gethostbyname(dest_addr)
my_socket = socket.create_connection(dest_addr, socket.getdefaulttimeout(), src_addr)
Is there something like my_socket.setproto()
? I haven't found such a function in the documentation.
Thank you, Guillaume