Develop and Download Open Source Software

Browse Subversion Repository

Diff of /branches/RB-1.1/ftpconn.c

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

revision 1 by hirohitohigashi, Wed Feb 18 08:06:53 2009 UTC revision 6 by hirohitohigashi, Fri Feb 20 02:19:48 2009 UTC
# Line 129  int ftp_connect(char *host, int port, st Line 129  int ftp_connect(char *host, int port, st
129          struct timeval tm; //tv_sec - tv_usec          struct timeval tm; //tv_sec - tv_usec
130          fd_set readfds;          fd_set readfds;
131    
132          tm.tv_sec = 4;          if (connect(sock, (struct sockaddr *)ftp_server, sizeof(struct sockaddr)) != 0)  {
133          tm.tv_usec = 0;              if (verbose) {
134                    perror("connect()");
135          FD_ZERO(&readfds);              }
136                        return -1;
         FD_SET(sock, &readfds);  
           
         if (select(sock+1, &readfds, NULL, NULL, &tm) < 0 ) {  
                 if (verbose) {  
                 perror("select()");  
                 }  
                 return -1;  
         } else {  
   
                 if (FD_ISSET(sock, &readfds)) {  
   
                         if (connect(sock, (struct sockaddr *)ftp_server, sizeof(struct sockaddr)) != 0)  {  
                         if (verbose) {  
                         perror("connect()");  
                         }  
                         return -1;  
                         }  
   
                         if (verbose) {  
                         printf("[ Connected ]\n");  
                         }  
                 }  
                 else {  
                         if (verbose)  
                         printf("[-] Timeout\n");  
                           
                         return -1;  
                 }  
137          }          }
138    
139            if (verbose) {
140                printf("[ Connected ]\n");
141            }
142            
143    
144          char buf[1024];          char buf[1024];
145          buf[1023] = '\0';          buf[1023] = '\0';
# Line 190  int ftp_connect(char *host, int port, st Line 166  int ftp_connect(char *host, int port, st
166                                  }                                  }
167                          return -1;                          return -1;
168                          }                          }
169                            buf[n] = '\0';
170    
171                          if (verbose) {                          if (verbose) {
172                          printf("[Server] %s\n", buf);                          printf("[Server] %s\n", buf);
# Line 203  int ftp_connect(char *host, int port, st Line 180  int ftp_connect(char *host, int port, st
180                  }                  }
181          }          }
182    
         buf[n] = '\0';  
183    
184          return sock; //Socket Descriptor returned!!          return sock; //Socket Descriptor returned!!
185  }  }

Legend:
Removed from v.1  
changed lines
  Added in v.6

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26