How to set the socket type and the protocol of a socket using create_connection?
Guillaume Comte
guillaume.comte10 at gmail.com
Mon Aug 20 05:14:01 EDT 2012
Hello everyone,
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
More information about the Python-list
mailing list