-
The main problem was that socket.type from Python standard library is not an integer anymore. It is EnumInt object which is used instead of bit field. To make the code compatible with both versions of Python we had to replace all exact value comparisons with bitwise masking.
0ee41b14