i am writing a web server thats serves one html file but when i go to my browser and type in localhost:50000/home/user/www/index.html i get something like this

viewd on my browser

heres my code for writing to a socket

n = read(connectfd, buffer, 255 );
	 	if (n < 0) error("ERROR reading from socket");
	 	 printf("Here is the message: %s\n",buffer);
	 	  FILE *open = NULL;
	 	  char err_msg[] = "Could not open";
	while((open = fopen("/home/rocco/ww/home.html","r") != EOF))
		n=write(connectfd, &open,1);
6 Years
Discussion Span
Last Post by dondajr

I say this in the most constructive way, learn how to program in C and then learn how to program client/server applications and then learn the HTTP protocol.

Line 8 is wrong.


Man, the way read and send data I belive is wrong

I don't know if the rules of here can post external links of tutorials.

I used this tutorial to learn how create a server with C.

I hope that help you

Link: http://shoe.bocks.com/net/

Moderator, if this goes against the rules, sorry for that.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.