/[pengfork]/pengfork/src/tcpip/tcpip.c
ViewVC logotype

Diff of /pengfork/src/tcpip/tcpip.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by chupa, Fri Nov 29 15:17:45 2002 UTC revision 1.5 by chupa, Sun Dec 1 01:19:07 2002 UTC
# Line 38  Line 38 
38  #include <netdb.h>  #include <netdb.h>
39  #include <fcntl.h>  #include <fcntl.h>
40    
41    #include "gettext.h"
42  #include "options.h"  #include "options.h"
43  #include "access.h"  #include "access.h"
44  #include "log.h"  #include "log.h"
# Line 63  tcpip_connect () Line 64  tcpip_connect ()
64    struct in_addr address;    struct in_addr address;
65    struct hostent *hp;    struct hostent *hp;
66    
67    if( !inet_aton(hostname, &address) )    if (!inet_aton (hostname, &address))
68      {      {
69        log(LOG_NOTICE, "Resolving %s...\n", hostname);        log (LOG_NOTICE, gettext ("Resolving %s...\n"), hostname);
70        if ((hp = gethostbyname (hostname)) == 0)        if ((hp = gethostbyname (hostname)) == 0)
71          {          {
72          log (LOG_ERR, "Unable to resolve %s: %s (%d)\n", hostname,            log (LOG_ERR, gettext ("Unable to resolve %s: %s (%d)\n"), hostname,
73               hstrerror(h_errno), h_errno);                 hstrerror (h_errno), h_errno);
74          return 0;            return 0;
75          }          }
76        address.s_addr= *((unsigned long *) hp->h_addr_list[0]);        address.s_addr = *((unsigned long *) hp->h_addr_list[0]);
77      }      }
78        
79    memset ((char *) &aol_addr, 0, sizeof (struct sockaddr_in));    memset ((char *) &aol_addr, 0, sizeof (struct sockaddr_in));
80    aol_addr.sin_family = AF_INET;    aol_addr.sin_family = AF_INET;
81    aol_addr.sin_port = htons (port);    aol_addr.sin_port = htons (port);
# Line 82  tcpip_connect () Line 83  tcpip_connect ()
83    
84    if ((tcpipfd = socket (PF_INET, SOCK_STREAM, 0)) < 0)    if ((tcpipfd = socket (PF_INET, SOCK_STREAM, 0)) < 0)
85      {      {
86        log (LOG_ERR, "Error while opening socket: %s (%d)\n",        log (LOG_ERR, gettext ("Error while opening socket: %s (%d)\n"),
87           strerror(errno), errno);             strerror (errno), errno);
88        return 0;        return 0;
89      }      }
90    
91    log(LOG_NOTICE,"Connecting to %s:%d ...\n", inet_ntoa(aol_addr.sin_addr),    log (LOG_NOTICE, gettext ("Connecting to %s:%d ...\n"), inet_ntoa (aol_addr.sin_addr),
92        port);         port);
93          
94    if (connect (tcpipfd, (struct sockaddr *) &aol_addr,    if (connect (tcpipfd, (struct sockaddr *) &aol_addr,
95                 sizeof (struct sockaddr_in)) == -1)                 sizeof (struct sockaddr_in)) == -1)
96      {      {
97        log (LOG_ERR, "Error while connecting to AOL: %s (%d)\n",strerror(errno),        log (LOG_ERR, gettext ("Error while connecting to AOL: %s (%d)\n"),
98           errno);             strerror (errno), errno);
99        return 0;        return 0;
100      }      }
101    
102    if (fcntl(tcpipfd, F_SETFL, O_NONBLOCK) < 0)    if (fcntl (tcpipfd, F_SETFL, O_NONBLOCK) < 0)
103      {      {
104        log (LOG_ERR, "Error while putting the socket non-blocking: %s(%d)\n",        log (LOG_ERR, gettext ("Error while putting the socket non-blocking: %s(%d)\n"),
105           strerror(errno), errno);             strerror (errno), errno);
106        return 0;        return 0;
107      }      }
108    
# Line 115  tcpip_close () Line 116  tcpip_close ()
116      {      {
117        if ((close (tcpipfd)) == -1)        if ((close (tcpipfd)) == -1)
118          {          {
119            log (LOG_WARNING, "Error while closing socket: %s(%d)\n",            log (LOG_WARNING, gettext ("Error while closing socket: %s(%d)\n"),
120               strerror(errno), errno);                 strerror (errno), errno);
121            return 0;            return 0;
122          }          }
123        tcpipfd = -1;        tcpipfd = -1;

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26