Thread: FTP server trouble

  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
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    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.

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, 12:51 PM
  2. Connection between proxy server and the server
    By vbx_wx in forum Networking/Device Communication
    Replies: 2
    Last Post: 02-07-2011, 01: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