I am implementing a basic client and server for this protocol, and I am trying to read the response from the server (which is functional) in the client. However, this never compiles as the client never reads the stdin.
client.c
...
fwrite(buffer, sizeof(uint8_t), file_request__get_packed_size(&request), stdout);
fflush(stdout);
// client works until here
// Allocate a buffer to hold the response
#define MAX_RESPONSE_SIZE 100001
uint8_t responseBuffer[MAX_RESPONSE_SIZE];
// Read the response from the server
// Here the program gets stuck
size_t responseSize = 0;
size_t bytesRead;
while (responseSize < MAX_RESPONSE_SIZE && (bytesRead = fread(responseBuffer + responseSize, 1, MAX_RESPONSE_SIZE - responseSize, stdin)) > 0) {
responseSize += bytesRead;
}
server.c (stdout is closed)
...
fwrite(serverResponse, sizeof(uint8_t), file_response__get_packed_size(&response), stdout);
fclose(stdout);
New contributor
vlad1d is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.