~bzr-mac/bzr-mac-installers/2.4

« back to all changes in this revision

Viewing changes to patches/paramiko/transport.py.patch

  • Committer: Gordon Tyler
  • Date: 2011-03-23 14:45:25 UTC
  • mfrom: (97.1.21 2.3)
  • Revision ID: gordon@doxxx.net-20110323144525-dle8u4obvmi36gaa
Updated for bzr 2.4b1 release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
--- paramiko/transport.py~      Wed Dec  8 15:38:05 2010
 
2
+++ paramiko/transport.py       Wed Dec  8 15:40:32 2010
 
3
@@ -285,15 +285,21 @@ class Transport (threading.Thread):
 
4
         if type(sock) is tuple:
 
5
             # connect to the given (host, port)
 
6
             hostname, port = sock
 
7
+            reason = 'No suitable address family'
 
8
             for (family, socktype, proto, canonname, sockaddr) in socket.getaddrinfo(hostname, port, socket.AF_UNSPEC, socket.SOCK_STREAM):
 
9
                 if socktype == socket.SOCK_STREAM:
 
10
                     af = family
 
11
                     addr = sockaddr
 
12
-                    break
 
13
+                    sock = socket.socket(af, socket.SOCK_STREAM)
 
14
+                    try:
 
15
+                        sock.connect((hostname, port))
 
16
+                    except socket.error, e:
 
17
+                        reason = str(e)
 
18
+                    else:
 
19
+                        break
 
20
             else:
 
21
-                raise SSHException('No suitable address family for %s' % hostname)
 
22
-            sock = socket.socket(af, socket.SOCK_STREAM)
 
23
-            sock.connect((hostname, port))
 
24
+                raise SSHException(
 
25
+                    'Unable to connect to %s: %s' % (hostname, reason))
 
26
         # okay, normal socket-ish flow here...
 
27
         threading.Thread.__init__(self)
 
28
         self.setDaemon(True)
 
29