Find the answer to your Linux question:
Results 1 to 3 of 3
I can`t recieve a reply from an ftp server. It connect()s, then server says "220 Blah-blah-blah after 3 minutes..." Then I do send(sockfd, "USER user", 9, 0); and want to ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Nov 2005
    Posts
    2

    Trying to create a small ftp client


    I can`t recieve a reply from an ftp server.
    It connect()s, then server says "220 Blah-blah-blah after 3 minutes..."
    Then I do send(sockfd, "USER user", 9, 0); and want to recieve an answer, something like "user user ok, enter password".

    I`m trying to do the following:

    fd_set readfds;
    ...
    FD_ZERO(&readfds);
    FD_SET(sockfd, &readfds);
    select(sockfd+1, &readfds, ...);
    if (FD_ISSET(sockfd, &readfds)) {
    FD_CLR(sockfd, &readfds);
    numbytes = recv(sockfd, buf, MAXDATASIZE-1, 0);
    printf("numbytes: %i\n", numbytes);
    } else {
    printf("hmmm\n");
    }

    but it always says "hmmm" instead of "enter password" or something.
    Sorry if the question is too dumb *).

  2. #2
    Linux Guru lakerdonald's Avatar
    Join Date
    Jun 2004
    Location
    St. Petersburg, FL
    Posts
    5,035
    Try making readfds a pointer:
    Code:
    fd_set *readfds;

  3. #3
    Just Joined!
    Join Date
    Nov 2005
    Posts
    2
    Actually, I have another question on the same topic now *).
    To send PORT command after logging in, I`ve to determine my (client`s) port and address.
    I`m trying to do it like this:

    datafd = socket(PF_INET, SOCK_STREAM, 0);
    clie_addr.sin_family = AF_INET;
    clie_addr.sin_port = 0;
    clie_addr.sin_addr.s_addr = INADDR_ANY;
    memset(&(clie_addr.sin_zero), '\0', ;
    bind(datafd, (struct sockaddr *)&clie_addr, sizeof(struct sockaddr));
    listen(datafd, 1);
    getsockname(datafd, (struct sockaddr*)&clie_addr, &clie_addr_len);

    Then I cout clie_addr.sin_port and it`s zero, such as clie_addr.sin_addr.s_addr.

    So the question is how to properly determine my address/port?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •