FTP client sends the CWD command, which deliberately makes the directory incorrect and returns a 550th error, but then all the other commands are wrong as well.

client is written in C by yourself

-sharpdefine BUFFER_SIZE 1024

char recv_buffer[BUFFER_SIZE];
char send_buffer[BUFFER_SIZE];

// ...
else if (start_with(cmd_read, "cd"))
{
    char *token;
    const char delim[2] = " \t";
    token = strtok(cmd_read, delim);
    char *path = strtok(NULL, delim);
    if (path == NULL)
    {
        printf("please input the path\n");
        continue;
    }
    sprintf(send_buffer, "CWD %s\r\n", path);
    send_cmd(client_socket, send_buffer);
    length = get_respond(client_socket, recv_buffer);
    printf("%s", recv_buffer);   
}


ftp server Why should I send an error message twice? How to deal with this?

Github source
PS:
FTP server I use windows

Mar.20,2021

Test finds windows 550-
there is a - that should represent multiple lines, so you have to receive 550End
PS TCP is a streaming protocol

Menu