Welcome fellow students, register yourself and dive into asking questions, giving answers and helping the community learn with you.

How to write to the client successfully? *Resolved*

+1 vote
asked Jun 10, 2015 in Pset6 by bezerk01 (530 points)
edited Jun 11, 2015 by bezerk01

Turns out I forgot a CRLF at the end. Oops. 

----

 

 

Hello, can someone help me on PSET6 making a web server? I basically have everything done except the part where I have to write data to the client/browser. If I understand correctly I would just write whatever was in the buffer to the client with:

write(cfd, body, length) //length is the total bytes in the buffer

I assume that would be it because aren't I writing the whole file the client requested? Anyhow, it doesn't seem to work, any expertise?

Thanks for any help!

Here's the url of the code: http://postimg.org/image/5bw92mogf/ 

 

----

And might I add, when I do add another write function to the code, and then request with the browser "/cat.html". I do get 200 OK, and the page does load but not the picture (I checked chmod). On the other hand when I request "/hello.html" I get 200 OK and the everything works fine. I think it has to do with how much I write to the client/browser but shouldn't one write function be enough? 

 

 

Thanks CS50xHelpers! 

 

1 Answer

+1 vote
answered Jun 12, 2015 by Faïza Harbi (11,960 points)
selected Jun 14, 2015 by bezerk01
 
Best answer
;) It happens to all of us!
Welcome to CS50xHelpers Q&A, where you can ask questions and receive answers from other members of the community.

192 questions

248 answers

217 comments

3,675 users

2 Online
0 Member And 2 Guest
...