+ if (_res.nscount == 1 || (try == 0 && ns == 0)) {
+ /*
+ * Don't use connect if we might
+ * still receive a response
+ * from another server.
+ */
+ if (connected == 0) {
+ if (connect(s, &_res.nsaddr_list[ns],
+ sizeof(struct sockaddr)) < 0) {
+#ifdef DEBUG
+ if (_res.options & RES_DEBUG)
+ perror("connect");
+#endif DEBUG
+ continue;
+ }
+ connected = 1;
+ }
+ if (send(s, buf, buflen, 0) != buflen) {
+#ifdef DEBUG
+ if (_res.options & RES_DEBUG)
+ perror("send");
+#endif DEBUG
+ continue;
+ }
+ } else {
+ /*
+ * Disconnect if we want to listen
+ * for responses from more than one server.
+ */
+ if (connected) {
+ (void) connect(s, &no_addr,
+ sizeof(no_addr));
+ connected = 0;
+ }
+#endif BSD
+ if (sendto(s, buf, buflen, 0,
+ &_res.nsaddr_list[ns],
+ sizeof(struct sockaddr)) != buflen) {
+#ifdef DEBUG
+ if (_res.options & RES_DEBUG)
+ perror("sendto");
+#endif DEBUG
+ continue;
+ }
+#if BSD >= 43
+ }
+#endif
+
+ /*
+ * Wait for reply
+ */
+ timeout.tv_sec = (_res.retrans << try);
+ if (try > 0)
+ timeout.tv_sec /= _res.nscount;
+ if (timeout.tv_sec <= 0)
+ timeout.tv_sec = 1;