Le mercredi 22 août 2012 04:10:43 UTC+2, Dennis Lee Bieber a écrit : > On Tue, 21 Aug 2012 10:00:28 -0700 (PDT), Guillaume Comte > > <guillaume.comt...@gmail.com> declaimed the following in > > gmane.comp.python.general: > > > > A later follow-up > > > Unfortunatly, my_socket.bind((src_addr, 1)) doesn't work. I get the error > > message: "socket.error: [Errno 49] Can't assign requested address"... > > > > > > > Since .bind() is used to set up a /listener/, the network stack > > (LINK layer) probably has to be tied to the IP address; that is, a valid > > "source" address needs to be supplied to .bind. > Do you mean that an alias is not a valid source address? Because ping.c can do it...
I've also tried changing the port to 3333 or 8080 but the same error happens. > > > > > > But when I try to set a source address, I still get the same error > > message... > > > > > > Does anyone know how I could build the IP header (I don't even know if it > > can be the solution but it's worth a try...)? > > > > Based upon http://linux.die.net/man/7/raw "Raw sockets allow new > > IPv4 protocols to be implemented in user space. A raw socket receives or > > sends the raw datagram not including link level headers. " implies that > > you need to build the entire IP packet for your ICMP message... That > > means you do NOT use socket methods to set fields -- you'll probably > > have to use something like the struct module to lay out the entire IP > > packet /including/ header contents, and then pass that as-is to the > > socket. > > > > -- > > Wulfraed Dennis Lee Bieber AF6VN > > wlfr...@ix.netcom.com HTTP://wlfraed.home.netcom.com/ -- http://mail.python.org/mailman/listinfo/python-list