On Mar 17, 11:14 am, Nobody <nob...@nowhere.com> wrote: > On Wed, 16 Mar 2011 22:36:07 -0700, moijes12 wrote: > > Traceback (most recent call last): > > File "getsockopt_handler.py", line 7, in ? > > send.bind((gethostbyname(gethostname()),50000)) > > socket.error: (99, 'Cannot assign requested address') > > Specifying a port number isn't meaningful for a raw socket. At the kernel > level, the sin_port field in a sockaddr_in structure is used for the IP > protocol (e.g. 6 for TCP), if it's used at all.
@ Chris : I am using windows xp sp2. @ Nobody : My main aim here is decode the IP header. I tried the below code and it seems to work.I have shifted to python 2.5 (though I think it was more of a code problem).My main problem is to decode the IP header s = socket(AF_INET,SOCK_RAW,IPPROTO_IP) r = socket(AF_INET,SOCK_RAW,IPPROTO_IP) r.bind(('',0)) s.connect(('localhost',0)) for i in range(10) : s.send(str(i)) data = r.recvfrom(256) hdr = r.getsockopt(SOL_IP, IP_OPTIONS, 20) print binascii.hexlify(hdr) r.close() s.close() Here it prints nothing.I'll try some more stuff and will post my findings in about 30 minutes. thanks moijes -- http://mail.python.org/mailman/listinfo/python-list