Path: csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'socket': 0.05; 'alias': 0.07; 'assign': 0.07; 'space.': 0.07; 'subject:skip:c 10': 0.07; 'subject:How': 0.09; 'happens.': 0.09; 'sockets': 0.09; 'subject:set': 0.09; 'subject:using': 0.09; 'to:addr:comp.lang.python': 0.09; 'cc:addr:python-list': 0.10; 'aug': 0.13; 'receives': 0.13; 'stack': 0.15; '(link': 0.16; '1))': 0.16; 'as-is': 0.16; 'follow-up': 0.16; 'headers.': 0.16; 'socket.': 0.16; 'subject:type': 0.16; 'url:linux': 0.16; 'later': 0.16; 'module': 0.19; 'sends': 0.22; 'struct': 0.22; 'cc:2**0': 0.23; 'work.': 0.23; "i've": 0.23; 'cc:no real name:2**0': 0.24; 'header': 0.24; 'pass': 0.25; 'tried': 0.25; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'implemented': 0.27; 'raw': 0.27; "doesn't": 0.28; 'implies': 0.29; 'protocols': 0.29; 'source': 0.29; 'probably': 0.29; 'error': 0.30; 'could': 0.32; 'url:home': 0.33; 'anyone': 0.33; "can't": 0.34; 'received:google.com': 0.34; 'subject:?': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'but': 0.36; 'does': 0.37; 'level': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'mean': 0.38; 'build': 0.39; 'skip:" 10': 0.40; 'your': 0.60; 'address': 0.60; 'skip:u 10': 0.60; 'link': 0.60; "you'll": 0.62; 'worth': 0.63; 'address,': 0.79; 'contents,': 0.84; 'address;': 0.91; 'dennis': 0.91; 'tied': 0.93 Newsgroups: comp.lang.python Date: Wed, 22 Aug 2012 00:29:37 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=130.243.27.200; posting-account=nArglgoAAAD1vIdoa_OKjmLHmRbfn9Os References: <4edc5ccb-9121-47b0-8ad4-2bf106735532@googlegroups.com> <50323dc7$0$6841$e4fe514c@news2.news.xs4all.nl> <7e4fbbae-a70f-42fc-82c9-a03f1a118136@googlegroups.com> User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-IP: 130.243.27.200 MIME-Version: 1.0 Subject: Re: How to set the socket type and the protocol of a socket using create_connection? From: Guillaume Comte To: comp.lang.python@googlegroups.com Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Message-ID: Lines: 67 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1345620586 news.xs4all.nl 6921 [2001:888:2000:d::a6]:40793 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:27612 Le mercredi 22 ao=FBt 2012 04:10:43 UTC+2, Dennis Lee Bieber a =E9crit=A0: > On Tue, 21 Aug 2012 10:00:28 -0700 (PDT), Guillaume Comte >=20 > declaimed the following in >=20 > gmane.comp.python.general: >=20 >=20 >=20 > A later follow-up >=20 > > Unfortunatly, my_socket.bind((src_addr, 1)) doesn't work. I get the err= or message: "socket.error: [Errno 49] Can't assign requested address"... >=20 > >=20 >=20 >=20 >=20 > Since .bind() is used to set up a /listener/, the network stack >=20 > (LINK layer) probably has to be tied to the IP address; that is, a valid >=20 > "source" address needs to be supplied to .bind. >=20 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 happen= s. >=20 >=20 >=20 >=20 > > But when I try to set a source address, I still get the same error mess= age... >=20 > >=20 >=20 > > 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...)? >=20 >=20 >=20 > Based upon http://linux.die.net/man/7/raw "Raw sockets allow new >=20 > IPv4 protocols to be implemented in user space. A raw socket receives or >=20 > sends the raw datagram not including link level headers. " implies that >=20 > you need to build the entire IP packet for your ICMP message... That >=20 > means you do NOT use socket methods to set fields -- you'll probably >=20 > have to use something like the struct module to lay out the entire IP >=20 > packet /including/ header contents, and then pass that as-is to the >=20 > socket. >=20 >=20 >=20 > --=20 >=20 > Wulfraed Dennis Lee Bieber AF6VN >=20 > wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/