Question: Please implemnet FTP client You need to implement following verbs in the ftp client 1. rls 2. get 3. put 4. bye To compile the

Please implemnet FTP client You need to implement following verbs in the ftp client 1. rls 2. get 3. put 4. bye To compile the server, first rename the file to ftpsvr.c - below is the line to comile. # gcc -o ftpsvr ftpsvr.c

files available:-

#include  #include  #include  #include  #include  #include  #define BUFSIZE 64000 int main(int argc, char **argv) { int sockfd, portno, n; struct sockaddr_in serveraddr; struct hostent *server; char *hostname; char buf[BUFSIZE]; int dsize[12] = {0}; /* check command line arguments */ if (argc != 3) { fprintf(stderr,"usage: %s   ", argv[0]); return 0; } hostname = argv[1]; portno = atoi(argv[2]); /* socket: create the socket */ sockfd = socket(AF_INET, SOCK_STREAM, 0); if (sockfd < 0) error("ERROR opening socket"); /* gethostbyname: get the server's DNS entry */ server = gethostbyname(hostname); if (server == NULL) { fprintf(stderr,"ERROR, no such host as %s ", hostname); return 0; } /* build the server's Internet address */ bzero((char *) &serveraddr, sizeof(serveraddr)); serveraddr.sin_family = AF_INET; bcopy((char *)server->h_addr, (char *)&serveraddr.sin_addr.s_addr, server->h_length); serveraddr.sin_port = htons(portno); /* connect: create a connection with the server */ if (connect(sockfd,(const struct sockaddr *) &serveraddr, sizeof(serveraddr)) < 0) error("ERROR connecting"); n = write(sockfd, "rls", 3); int rd = read(sockfd,buf,BUFSIZE); printf( "%s",buf); memset(buf,0x00,BUFSIZE); n = write(sockfd, "get:test.c ", 14); rd = read(sockfd,buf,BUFSIZE); printf( "%s",buf); //n = write(sockfd, "PUT:file:SIZE", 3); n = write(sockfd, "bye", 3); close(sockfd); return 0; } 

more files:-

#include  #include  #include  #include  #include  #include  #define BUFSIZE 64000 int main(int argc, char **argv) { int sockfd, portno, n; struct sockaddr_in serveraddr; struct hostent *server; char *hostname; char buf[BUFSIZE]; int dsize[12] = {0}; /* check command line arguments */ if (argc != 3) { fprintf(stderr,"usage: %s   ", argv[0]); return 0; } hostname = argv[1]; portno = atoi(argv[2]); /* socket: create the socket */ sockfd = socket(AF_INET, SOCK_STREAM, 0); if (sockfd < 0) error("ERROR opening socket"); /* gethostbyname: get the server's DNS entry */ server = gethostbyname(hostname); if (server == NULL) { fprintf(stderr,"ERROR, no such host as %s ", hostname); return 0; } /* build the server's Internet address */ bzero((char *) &serveraddr, sizeof(serveraddr)); serveraddr.sin_family = AF_INET; bcopy((char *)server->h_addr, (char *)&serveraddr.sin_addr.s_addr, server->h_length); serveraddr.sin_port = htons(portno); /* connect: create a connection with the server */ if (connect(sockfd,(const struct sockaddr *) &serveraddr, sizeof(serveraddr)) < 0) error("ERROR connecting"); n = write(sockfd, "rls", 3); int rd = read(sockfd,buf,BUFSIZE); printf( "%s",buf); memset(buf,0x00,BUFSIZE); n = write(sockfd, "get:test.c ", 14); rd = read(sockfd,buf,BUFSIZE); printf( "%s",buf); //n = write(sockfd, "PUT:file:SIZE", 3); n = write(sockfd, "bye", 3); close(sockfd); return 0; } 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!