[master] use socket.error, not OSError as an expected exception for some cases

the former isn't derived from the latter for older versions of python.