一个Linux C做的TCP文件传输的代码(二)

2014-11-24 02:38:54 · 作者: · 浏览: 7
n't open the file: %s\n", buff);
exit(1);
}


while(count = read(connfd, buff, BUFFERSIZE)) {
if (count < 0) {
fprintf(stderr, "connfd read error\n");
exit(1);
}
if (writen(filefd, buff, count) < 0) {
fprintf(stderr, "writing to filefd error\n");
exit(1);
}
}
Close(filefd);
Close(connfd);
printf("file %s received!\n", filename);
}
Close(listenfd);
//////////////////////////////////////////////////////////


return 0;
}


________________________________________________________________________