- /* turn on network debugging? */
- if (tTd(16, 14))
- {
- 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 */
-#ifdef NVMUNIX
- bind(s, &SendmailAddress, sizeof SendmailAddress, 0);
- if (connect(s, &SendmailAddress, sizeof SendmailAddress, 0) < 0)
-#else NVMUNIX
- SendmailAddress.sin_family = AF_INET;
- if (connect(s,
- (struct sockaddr *)&SendmailAddress, sizeof SendmailAddress) < 0)
-#endif NVMUNIX
- {
+ 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 */