--- nbsmtp.c Sat Apr 7 01:09:01 2001 +++ nbsmtp_af.c Fri Sep 28 15:00:58 2001 @@ -126,17 +126,17 @@ } if(buffer_mail() > 0){ - fprintf(stdlog, "Error in buffer_mail\n"); + fprintf(stderr, "Error in buffer_mail\n"); return 1; } if(parse_mail()){ - fprintf(stdlog, "Error in parse_mail\n"); + fprintf(stderr, "Error in parse_mail\n"); return 1; } if(send_mail()){ - fprintf(stdlog, "Error in send_mail\n"); + fprintf(stderr, "Error in send_mail\n"); return 1; } @@ -365,9 +365,11 @@ struct sockaddr_in addr; servp = gethostbyname(host); - if(servp == NULL) - return 0; - + if(servp == NULL) { + fprintf (stderr, "gethostbyname(%s) failed\n", host); + return -1; + } + if(debug_level){ fprintf(stdlog,"got name: %s\n",servp->h_name); fprintf(stdlog,"got IP: %s\n",inet_ntoa(*((struct in_addr *)servp->h_addr))); @@ -379,16 +381,19 @@ return sockfd; } else { if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1) - return 0; + return sockfd; addr.sin_family = AF_INET; addr.sin_port = htons(port); addr.sin_addr = *((struct in_addr *)servp->h_addr); bzero(&(addr.sin_zero), 8); - if (connect(sockfd, (struct sockaddr *)&addr, sizeof(struct sockaddr)) == -1) - return 0; - + if (connect(sockfd, (struct sockaddr *)&addr, sizeof(struct sockaddr)) == -1) { + perror("Connecting to mail server"); + close (sockfd); + return -1; + } + return sockfd; } }