[python-win32] [issue570] [windows server 2003]Datagram Socket on windows server 2003 (python winsock not work well))

Alan Gauld alan.gauld at btinternet.com
Mon Jul 13 09:05:42 CEST 2015


On 13/07/15 03:57, 王利强 wrote:

> New submission from johnny_wang:
>
> when use: s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
>            s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
>            s.setsockopt(socket.IPPROTO_IP, socket.IP_HDRINCL, 1)
>            s.bind(('', 1029))
>            while True
>                try :
>                    databuffer, (raddress, rport) = s.recvfrom(1024)
>                except socket.timeout:
>                    logging.error("Write timeout on socket")
>                    continue
> databuffer is nothing in it!

How do you know?
You read forever and never exit the loop (unless you get a different 
exception).
You never do anything with databuffer.

So how do you know there is nothing in it? Are you stepping through
the code in a debugger maybe? If so tell us what you are
doing to come to this conclusion.

Or if this is only partial code show us something that we can run
and reproduce the problem.

And while you are doing that please give the Python version

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the python-win32 mailing list