Like Tree8Likes

FTP server trouble

This is a discussion on FTP server trouble within the Networking/Device Communication forums, part of the General Programming Boards category; So how would i set conditions in the for loop if i do not know the size of the file ...

  1. #16
    Registered User Annonymous's Avatar
    Join Date
    Apr 2011
    Location
    Jackson, New Jersey, United States
    Posts
    302
    So how would i set conditions in the for loop if i do not know the size of the file until the end of the loop? I figure thats why the server is making an extra read call. It is looping until the data is read, then looping one extra time resulting in the extra call to read.

  2. #17
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,650
    Code:
    readfd = read(newsockfd, buffer, sizeof(buffer));
    if(readfd < 0)
    {
        fprintf(stderr, "%s. READ(s)\n", strerror(errno));
        exit(1);
    }
     
    //Test to see if the buffer is blank.
    if(readfd == 0)
    {
        printf("Null buffer. READ()\n");
        exit(1);
    }
    Read the manual on read() and re-examine your logic.

    Oh, and I wouldn't call the variable receiving the return value from read "readfd", as it implies it's a read file descriptor. Use something a little more sane and descriptive, like "bytes_read".

  3. #18
    Registered User Annonymous's Avatar
    Join Date
    Apr 2011
    Location
    Jackson, New Jersey, United States
    Posts
    302
    Thanks rags_to_riches, I solved the problem.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. server/client trouble yet again lol
    By Annonymous in forum Networking/Device Communication
    Replies: 8
    Last Post: 11-14-2011, 11:51 AM
  2. Connection between proxy server and the server
    By vbx_wx in forum Networking/Device Communication
    Replies: 2
    Last Post: 02-07-2011, 12:51 PM
  3. Send integers to server and server can read them?
    By rahul.hbk007 in forum C Programming
    Replies: 7
    Last Post: 05-02-2010, 10:14 AM
  4. C#: Server.Execute() and Server.Transfer()
    By Grayson_Peddie in forum Networking/Device Communication
    Replies: 3
    Last Post: 09-24-2003, 06:50 PM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21