I implement a simple connection between a client and a server in C. On the client side, I am in a loop, reading from a file; each time BUFFER_SIZE bytes and sending them to the server (do not load error handling).
//client side
bytesNumInput = read(inputFileFD,bufInput,BUFFER_SIZE)
bytesSend = write(sockfd,bufInput,bytesNumInput)
Of course, the server is also in a loop.
//server side
bytesRecv = read(sockfd,bufOutput,bytesNumInput)
Now my questions are:
- Is it possible to get EOF in the middle of a connection if the server is reading faster than the client?
- Does the read function expect to receive all the data, or is it the same as reading from a file?
- Is it possible that the server will handle 2 read iterations in 1 write iteration?
source
share