read() return positive but there is nothing in recvline
<p>I'm using socket in C, and I want to ask, is that normal read return positive value but read nothing?</p>

<pre><code>#define MAXLINE 1234
....
upload(){
....
    long long unsigned int byteNum = 0, count = 0;
    ssize_t nbyte;
    char sendline[MAXLINE], recvline[MAXLINE];
....
    while((count += byteNum) &lt; filesize) {
        bzero(sendline, MAXLINE);
        if((byteNum = fread(&amp;sendline, sizeof(char), MAXLINE, fp)) != MAXLINE ){
            printf("End of file or Error\n");
        }
        if((nbyte = write(sockfd, sendline, byteNum)) &lt; 0){
            printf("upload write error at count = %llu\n", count);
            exit(1);
        }read(sockfd, recvline, MAXLINE);
    }
....

}

download(){
....
    long long unsigned int filesize, count;
    ssize_t nbyte;
    char sendline[MAXLINE], recvline[MAXLINE];
....
        while((count += n) &lt; filesize){
                bzero(recvline, MAXLINE);
                if((nbyte = read(sockfd, recvline, MAXLINE)) &lt; 0){
                    printf("download read fail at %llu\n", count);
                    exit(1);
                }if(nbyte == 0){
                    printf("nbyte = 0!!\n");
                    return;
                }if(strlen(recvline) == 0){
                    printf("nbyte = %zd recvline = 0\n", nbyte);
                    return;
                }
                n = strlen(recvline);
                if(fwrite(&amp;recvline, sizeof(char), nbyte, fp) != nbyte)
                    printf("end of file or error\n");
                write(sockfd, "ok", 2);                 
            }
....
}
</code></pre>

<p>result</p>

<pre><code>nbyte = 1234 recvline = 0
</code></pre>

<p>it happens only when the file size is large(in test case, it's about 5GB), but in about 50MB it's work well.</p>

<p>What might be wrong?</p>

<hr>

<p>I have changed the type of nbyte(from unsigned long long into ssize_t)</p>

<p>but the result remains the same</p>