CA-116369: Fix compatibility problem with Python 2.6

In Python 2.6 socket.error class inherit from IOError. For this reason
checking for socket.error exception after IOError cause the catch path to
never get taken. Fix this problem checking for socket.error before IOError.

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>