Introduction
Announcements

Schedule
Labs
Assignments
TA office hours

Tests, exam

Topic videos
Some course notes
Extra problems
Lecture recordings

Discussion board

Grades so far

Assignment four questions and answers

Here are some questions and answers about assignment four, and other notes. Suggestions for additions to this list are welcome (e.g. via e-mail).

Click on the highlighted text to expand an item. [EXPAND ALL]


Example code: |+|
Q: How does the code in lookup.c work? |+|
Q: Can I modify [...] in the starter code? |+|
Just about the easiest way to write a fixed message to a socket is |+|
Q: Hey, you're using sizeof to find the number of elements in the array! |+|
Q: What is the first argument to select()? |+|
Q: What do I put in the fd set passed as the second argument to select()? |+|
Q: What value do I use as the timeout for select()? Does it matter? |+|
Q: How do we test how our program behaves on partial reads? |+|
Q: What does your memnewline() do? |+|
Q: Is it ok to use O_NONBLOCK instead of select()? |+|
Review of the FD_* macros: |+|
When the other side of a socket connection disconnects, |+|
Q: What's this "localhost" thing about? |+|
Note that you must not trust the other side of the connection to send appropriately-sized messages. |+|
Q: How does chatclient's read_line_from_server() work? |+|
Q: What do I need in the "struct server" representing one server I'm connected to? |+|
Q: So what do I do with all of those static variables in read_line_from_server() in chatclient.c? |+|
Q: What should I replace [...something in a socket example or some code from the net...] by in my code? |+|
Q: How do you run gdb if your program needs command-line arguments? |+|
Q: How do I connect to a chatsvr using nc? |+|
Q: Do we have to check all system calls for error return values? |+|
Q: Is the chatbridge program also an infinite loop? |+|
Q: I keep getting the error "bind: Address already in use" |+|
Q: Once I get data from one file descriptor, I can't seem to receive data from any of the other |+|
Q: I got an unexpected message from my server saying that someone else had connected |+|
Q: Can I modify chatsvr.h to add declarations? Or can I submit a "chatbridge.h"? |+|
Q: When the handout says "everything which anyone types gets relayed to everyone", |+|
Q: What if someone using chatclient uses a handle of "bridge"? |+|
Q: When viewing messages from my program in 'nc' it goes to the left margin |+|
Q: Do we have to deal with the clients in "round-robin" fashion |+|
Q: Should our program use pthreads? fork? |+|