How to emulate socket.socketpair on Windows
The standard Python function socket.socketpair is unfortunately not available on Windows (as of Python 3.4.1), how can I write a replacement that works on both Unix and Windows? Python 3.5 includes Windows support for socket.socketpair() . For Python 2.7+, you can use the backports.socketpair package (which I authored) on PyPi: import socket import backports.socketpair s1, s2 = socket.socketpair() import socket import errno def create_sock_pair(port=0): """Create socket pair. If socket.socketpair isn't available, we emulate it. """ # See if socketpair() is available. have_socketpair = hasattr