setbuf(stdout,NULL);
. To switch to line buffering, which should work fine as well, use setlinebuf(stdout)
.
NOTE: There is no template for this homework. It is up to you to create the necessary directory, Makefile, etc.
Here is an example transcript with 3 connected telnet clients:
./hw4 8081 Got connection (Client 1) Got connection (Client 2) Client 2 set name to Jakob Client 1 set name to Musa Jakob said: Hi Musa Got connection (Client 3) Client 3 set name to Tomas Jakob said: Hi Tomas Tomas said: Hi everyone Jakob whispered to Musa: Wasn't he the TA last year? What's he doing here? Jakob said: Bye bye Jakob disconnected. A total of 125 bytes received from Jakob. Musa said: Bye Tomas Musa disconnected. A total of 26 bytes received from Musa. Tomas disconnected. A total of 29 bytes received from Tomas. client session 1: telnet localhost 8081 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. name Jakob Client 1 set name to Musa Hi Musa say Hi Musa Client 3 set name to Tomas say Hi Tomas Tomas> Hi everyone whisper Musa Wasn't he the TA last year? What's he doing here? say Bye bye ^] telnet> close Connection closed. client session 2: telnet localhost 8081 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. Client 2 set name to Jakob name Musa Jakob> Hi Musa Client 3 set name to Tomas Jakob> Hi Tomas Tomas> Hi everyone ~Jakob> Wasn't he the TA last year? What's he doing here? Jakob> Bye bye Jakob disconnected. say Bye Tomas ^] telnet> close Connection closed. client session 3: telnet localhost 8081 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. name Tomas Jakob> Hi Tomas say Hi everyone Jakob> Bye bye Jakob disconnected. Musa> Bye Tomas Musa disconnected. ^] telnet> close Connection closed.
svn up
in your /pub
. The grading script is in /pub/grading-scripts/hw4/. To run the grading script:
./hw4_score username port score_file
The grading script runs the server and simulate multiple client telnet connection using a python library named telnetlib. It saves output from server and all the clients to files and look for appropriate output in them. You will need to follow the output format exactly with the example output so that grading script finds the output it is looking for.
Following is the sample output of grading script:
[SUCCESS] name works [1]: 1 [SUCCESS] musa and tomas got message from jakob for say [1]: 1 [SUCCESS] james, tomas, jakob, bala got message from musa for say [1]: 1 [SUCCESS] whisper worked between musa and tomas [1.5]: 1.5 [SUCCESS] correct statistics [1.5]: 1.5 Total score: 6Following is the transcript used for grading
Server: Got connection (Client 1) Client 1 set name to musa musa said: Hi from musa Got connection (Client 2) Client 2 set name to tomas tomas said: Hi from tomas closing connection... musa disconnected. A total of 27 bytes received from musa. closing connection... tomas disconnected. A total of 29 bytes received from tomas. Got connection (Client 1) Client 1 set name to musa Got connection (Client 2) Client 2 set name to tomas Got connection (Client 3) Client 3 set name to jakob musa said: hi jakob tomas said: hi jakob jakob said: hi musa, tomas musa whispered to tomas: this message is between you and me only tomas whispered to musa: sure Got connection (Client 4) Client 4 set name to bala Got connection (Client 5) Client 5 set name to james musa said: Hi James, good to see you! musa: Client 2 set name to tomas Client 3 set name to jakob tomas> hi jakob jakob> hi musa, tomas ~tomas> sure Client 4 set name to bala Client 5 set name to james tomas: Client 3 set name to jakob musa> hi jakob jakob> hi musa, tomas ~musa> this message is between you and me only Client 4 set name to bala Client 5 set name to james musa> Hi James, good to see you! jakob: musa> hi jakob tomas> hi jakob Client 4 set name to bala Client 5 set name to james musa> Hi James, good to see you! bala: Client 5 set name to james musa> Hi James, good to see you! james: musa> Hi James, good to see you!
Copyright 2016 The Board of Trustees of the University of Illinois.webmaster@cs.uic.edu |
WISEST Helping Women Faculty Advance Funded by NSF | ![]() | ![]() |