+ if (usesecureport)
+ {
+ int rport = IPPORT_RESERVED - 1;
+
+ s = rresvport(&rport);
+ }
+ else
+ {
+ s = socket(AF_INET, SOCK_STREAM, 0);
+ }
+ if (s < 0)
+ {
+ sav_errno = errno;
+ syserr("makeconnection: no socket");
+ goto failure;
+ }
+
+ if (tTd(16, 1))
+ printf("makeconnection: fd=%d\n", s);
+
+ /* turn on network debugging? */
+ if (tTd(16, 101))
+ {
+ int on = 1;
+ (void) setsockopt(DaemonSocket, SOL_SOCKET, SO_DEBUG,
+ (char *)&on, sizeof on);
+ }
+ if (CurEnv->e_xfp != NULL)
+ (void) fflush(CurEnv->e_xfp); /* for debugging */
+ errno = 0; /* for debugging */
+ addr.sin_family = AF_INET;
+ if (connect(s, (struct sockaddr *) &addr, sizeof addr) >= 0)
+ break;
+
+ /* couldn't connect.... figure out why */
+ sav_errno = errno;
+ (void) close(s);
+ if (hp && hp->h_addr_list[i])
+ {
+ if (tTd(16, 1))
+ printf("Connect failed; trying new address....\n");
+ bcopy(hp->h_addr_list[i++], (char *) &addr.sin_addr,
+ hp->h_length);
+ continue;
+ }