xmpp/xmpp.go
changeset 135 a4755a42af19
parent 134 80b764fa2f08
child 138 065f54e291c7
equal deleted inserted replaced
134:80b764fa2f08 135:a4755a42af19
   117 	}
   117 	}
   118 
   118 
   119 	var tcp *net.TCPConn
   119 	var tcp *net.TCPConn
   120 	for _, srv := range srvs {
   120 	for _, srv := range srvs {
   121 		addrStr := fmt.Sprintf("%s:%d", srv.Target, srv.Port)
   121 		addrStr := fmt.Sprintf("%s:%d", srv.Target, srv.Port)
   122 		addr, err := net.ResolveTCPAddr("tcp", addrStr)
   122 		var addr *net.TCPAddr
       
   123 		addr, err = net.ResolveTCPAddr("tcp", addrStr)
   123 		if err != nil {
   124 		if err != nil {
   124 			err = fmt.Errorf("ResolveTCPAddr(%s): %s",
   125 			err = fmt.Errorf("ResolveTCPAddr(%s): %s",
   125 				addrStr, err.Error())
   126 				addrStr, err.Error())
   126 			continue
   127 			continue
   127 		}
   128 		}
   128 		tcp, err = net.DialTCP("tcp", nil, addr)
   129 		tcp, err = net.DialTCP("tcp", nil, addr)
   129 		if err == nil {
   130 		if tcp != nil {
   130 			break
   131 			break
   131 		}
   132 		}
   132 		err = fmt.Errorf("DialTCP(%s): %s", addr, err)
       
   133 	}
   133 	}
   134 	if tcp == nil {
   134 	if tcp == nil {
   135 		return nil, err
   135 		return nil, err
   136 	}
   136 	}
   137 
   137