getsockopt

Fabian Deutsch fabian.deutsch at gmx.de
Fri Dec 16 08:55:10 CET 2005


Forgot:
> The lines:
> s = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP)
> s.bind(('',4500))
> while 1:    # Run until cancelled
> 	message, client = s.recvfrom(1400) # <=256 byte datagram
>         hdr = s.getsockopt (SOL_IP, IP_OPTIONS, 20)
>         print "Client connected:", client
>         print "HDR:" + binascii.hexlify(hdr)
> 
If you want to test this, be rot and try

     echo asd | nc -u 127.0.0.1 4500

to create some packets ...

This should do it.
- fabiand




More information about the Python-list mailing list