Section notes for CS162 Section #14, May 6, 2003 Hakim Weatherspoon - Administrivia - Office hours this week Mon 12:00-1:00 6th floor Soda alcove Tue 3:30- 4:30 6th floor Soda alcove - Project 4 Code Due, Wed 5/14 - Hand back midterm2 and Project 3 Initial and Final Design Doc - Design Reviews Wed 5/7/2003 from 9:00am-4:00pm. 15 minutes each. - I will be out of town Thurs 5/8/2003 - Mon 5/12/2003. - Project 4 Design Docs Documents should be a 9 +- 1 PAGE. QUIZ We have a star topology network where the center node is a broadcast server. The edge nodes can send a msg to the server that will be broadcast to all other edge nodes. What state is needed per client? connected file descriptor for connection name msg buffer size of msg in buffer Given that we can only use static size buffers and that the call to read may not return a complete msg, how does the server make sure that it has all the bytes for a msg before broadcasting msg to other nodes? Write solution in pseudocode (The header of a msg includes a length [integer]) That is read(fd, buffer, size) may return less than size bytes. 1) readBytes = read(client_fd, client_buf+client_buf_sz, MAX_BUF_SZ - client_buf_sz); 2) msg_length = (int)client_buf; // first four bytes; length = msg_length + sizeof(int); if(client_buf_sz >= length) { broadcast( client_buf, length ); client_buf_sz -= length; memcpy(client_buf, &client_buf[length], client_buf_sz); } What are the errors? readBytes returns -1 (close connection). Project 4 II Chat UI Expectation 1) Client sends msg to server when user hits enter ('\n'); Do not echo msg on the clients console who sent msg. 2) On a received msg: display username at start of line (i.e. user that sent msg) and rest of msg. 3) You do not need malloc. Use all static size buffers. You can assume 80 characters per line and no more than three clients. 4) We will first test their chat on their Nachos implementation. If that does not work, we will test their chat on our Nachos 4) Data Structures: Server - struct per client includes fd, name, buffer, size Client -