I am have written some code to send a file using TCP sockets in linux. On the receiving end I have the code fragment shown below. It works great and writes the file correctly, but since read blocks it just sits here once all the bytes have been written.
I was wondering if anyone could point me in the right direction to break out of the loop once the last byte has been written. Thanks.
Code:while(read_size = read(sd, message, sizeof(message))>0){ written=write(pfd, message, strlen(message)); }