diff --git a/APP_Framework/Applications/app_test/test_ftpclient_final/ftpserver.c b/APP_Framework/Applications/app_test/test_ftpclient_final/ftpserver.c index 4efc7b092..b9c895159 100644 --- a/APP_Framework/Applications/app_test/test_ftpclient_final/ftpserver.c +++ b/APP_Framework/Applications/app_test/test_ftpclient_final/ftpserver.c @@ -164,7 +164,10 @@ char* GetRespond(char* buf, int it,int *ret,int cmd_fd) { char* buff = (char*)malloc(file_size); fread(buf, 1, file_size, file); - write(fd_map[cmd_fd], buff, strlen(buff)); + int size = write(fd_map[cmd_fd], buff, strlen(buff)); + if (size < 0) { + printf("failed to send message\n"); + } fclose(file); free(buff); @@ -180,7 +183,10 @@ char* GetRespond(char* buf, int it,int *ret,int cmd_fd) { char* buff = (char*)malloc(5000); - read(fd_map[cmd_fd], buff, sizeof(buff)); + int size = read(fd_map[cmd_fd], buff, 5000); + while (size < 0) { + size = read(fd_map[cmd_fd], buff, 5000); + } fwrite(buff, 1, strlen(buff), file); fclose(file); @@ -207,7 +213,7 @@ void *RecvSend(void *arg) char buf[100]; memset(buf, 0, sizeof(buf)); int size; - size = read(cmd_fd, buf, sizeof(buf)); + size = read(cmd_fd, buf, 100); if (size < 0) { printf("Failed to read or client closed\n");