I'm writing some client/server application for my class assignment.
The client should read the input from STDIN and send it to the socket.
My program stack on those lines:
char buffer [STD_BUFF_SIZE];
int len = fread(&buffer,sizeof(buffer),1,stdin);
(I'm passing some text to it's STDIN from some text file...)
1. The line "Before fread." isn't printed until I press 'enter' key, why is that?
2. The line "After fread." isn't printed at all, that mean that the fread function never returns, why? how to solve this?
The client should get the commands that need to be executed on the other side from ARGV and the standard input from it's STDIN.
I can't use getline because my lecturer told me that the input may be binary. He told me that fread should be good for this purpose. The input from stdin may come in different sizes. How to properly get it into a buffer, so I can send it to the server?
Thanks in advance.