[issue19530] cross thread shutdown of UDP socket exhibits unexpected behavior

Charles-François Natali report at bugs.python.org
Sun Nov 10 09:47:16 CET 2013


Charles-François Natali added the comment:

> After some research...
>
>> Which is normal, since UDP sockets aren't connected.
>
> But UDP sockets can be connected!
>

No, they can't.
"Connecting" a UDP socket doesn't established a duplex connection like
in TCP: it's just a shortand for not having to repeat the destination
address upon every sendto()/sendmsg().

> FYI, the FreeBSD (and OpenBSD) shutdown manpages anticipate calling shutdown on DGRAM sockets.  And the Linux connect manpage discusses connecting DGRAM sockets.

And since shutdown() is designed for duplex connection, it doesn't
really make much sense. It might very well work when you passe SHUT_RD
because it can be interpreted as triggering an EOF, but I wouldn't
rely on this.

> Here is the updated Python code.  I do expect to try to report this upstream.  (Also, I now have C/pthreads code, if you want to see it.  As expected, C behaves identically.)

So you see it's not a Python "bug". It's really not a bug at all, but
if you want to report this upstream, have fun :-).

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19530>
_______________________________________


More information about the Python-bugs-list mailing list