update ftpserver

This commit is contained in:
ambrumf 2023-10-16 18:12:52 +08:00
parent f5589fbaa4
commit 7c5d473af2
1 changed files with 9 additions and 3 deletions

View File

@ -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");