At first am checking the arguments and creating a socket which can connect to a server and defined a file where I can write my HTTP request and when there is a data, I need to Process the line that we have read, through getline and after this I should check end of stream and at the end of stream I need to close the stream and exit.but I do not know how can I check the Endofline...and whther the format written by me are correct
int main(int argc, char *argv[])
{
if(argc<2) //checking arguments
{
printf("expected a name for resolving");
exit(1);
}
int sock = createSocket(argv[1], argv[2]);
FILE *stream = getStream(sock);
printf("\n###### CLIENT IS SENDING THE FOLLOWING TO THE SERVER\n");
fputs("GET /HTTP/1.0\n Host:Google.com\n Connection:close \r\n\r\n",stream);
while(1)
{
char *string = NULL;
int len = getLine(&string, stream);
int numbytes=0;
printf("The length of string: %d\n",len);
printf("#####CLIENT RECEIVED THE FOLLOWING FROM SERVER \n%s", string);
while (fgetc(stream) != EOF)
++numbytes;
fclose(stream);
printf("##### Connection closed by server");
exit(EXIT_SUCCESS);
free(string);
}
}