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);
		}
			
}

Recommended Answers

All 2 Replies

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.