--- In [email protected], Ahmed Shabana <unlimited...@...> wrote:
>
>       sprintf(message,"GET /index.html\n");
> 
>       write(sfd,message,sizeof(message));
>       
>               int nread;char buffer[1000];
>               nread = read(sfd,buffer,sizeof(buffer));

In your write(), you only need to write the number of characters in
the message, not the whole array. So you could do:

    write(sfd, message, strlen(message) + 1);

The +1 is required to include the string terminator character ('\0')
in the message, although the receiver might not need it if it uses the
number of characters received to give the length of the string.

You could also increase the size of message to 1000 and re-use it,
instead of using additional variable buffer[].

John

Reply via email to