@@ -505,25 +505,10 @@ def set_debuglevel(self, level):
505
505
506
506
def connect (self ):
507
507
"""Connect to the host and port specified in __init__."""
508
- msg = "getaddrinfo returns an empty list"
509
- for res in socket .getaddrinfo (self .host , self .port , 0 ,
510
- socket .SOCK_STREAM ):
511
- af , socktype , proto , canonname , sa = res
512
- try :
513
- self .sock = socket .socket (af , socktype , proto )
514
- if self .debuglevel > 0 :
515
- print "connect: (%s, %s)" % (self .host , self .port )
516
- self .sock .connect (sa )
517
- except socket .error , msg :
518
- if self .debuglevel > 0 :
519
- print 'connect fail:' , (self .host , self .port )
520
- if self .sock :
521
- self .sock .close ()
522
- self .sock = None
523
- continue
524
- break
525
- if not self .sock :
526
- raise socket .error , msg
508
+ self .sock = socket .socket (socket .AF_INET , socket .SOCK_STREAM )
509
+ if self .debuglevel > 0 :
510
+ print "connect: (%s, %s)" % (self .host , self .port )
511
+ self .sock .connect ((self .host , self .port ))
527
512
528
513
def close (self ):
529
514
"""Close the connection to the HTTP server."""
0 commit comments