codeplea/Hands-On-Network-Programming-with-C

->next for client

Closed this issue · 6 comments

Tried running web_server2.c which did not render, I think adding next got it working?

struct client_info *next = client->next;

https://github.com/codeplea/Hands-On-Network-Programming-with-C/blob/master/chap07/web_server2.c#L314

Can you try again with the unaltered code? If you get an error, please post the exact message you're getting, and I can help you solve it. Do you have a copy of book?

Edit: I was mistaken. ->next is the correct fix. See below.

I haven't had a copy of your book.

Clone from your repo.

Ss-MacBook-Pro:chap07 s$ cc --version
Apple LLVM version 10.0.1 (clang-1001.0.46.4)
Target: x86_64-apple-darwin18.7.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

Ss-MacBook-Pro:chap07 s$ cc web_server2.c
Ss-MacBook-Pro:chap07 s$ ./a.out 
Configuring local address...
Creating socket...
Binding socket to local address...
Listening...
New connection from 127.0.0.1.

Access to http://127.0.0.1:8080/ did not shown any error messages, just hang state with springing icon on the web browser's tab.

Thanks for the report. Did you try web_server.c? Does it work, or is it just web_server2.c with the problem?

I'm sorry, the advice I gave before is wrong. Adding ->next where you had it is the proper fix.

So web_server.c is explained and worked out through the book. It's gotten a lot of scrutiny. web_server2.c was just included as an example of how global state can be removed from web_server.c. It's not really shown in the book, so it seems this bug made it through to the repo. I will fix it shortly.

Thanks for bringing this to my attention, and sorry for the knee-jerk reactive before. I really appreciate the bug fix.

No problem, I'm glad I did help.

Ok. I have updated the repo with the fix. There was also a small problem in drop_client() that is now also brought up to align with the fix already in web_server.c.