This matches CPython behaviour on Linux: a socket that is new and not listening or connected is considered "hung up". Thanks to @rkojedzinszky for the initial patch, PR #3457.