I am writing code for a webserver and am trying to send a html file called index.html over a TCP socket. How would I do this?
At the moment I am trying to read the contents of the file and then send them over the connection. However, the page is not being received correctly. I suspect that I am using the wrong function to read and something to do with the data being read as ASCII and not being converted back. But am not sure what else to do =s and cannot find anything online. Please help!
fgets(send_buffer, MAX_LEN, sendFile);
I have tried using fgetc and fread but they do not work. Fgets seems to be the only function that actually seems to read and transmit the data but on the browser it shows up as jibberish :s