A connection is uniquely identied by the socket

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: tfgets, that times out and returns a NULL pointer if it does not receive an input line on stdin within 5 seconds. ¯ ¯ ¯ ¯ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Your function should be implemented in a package called tfgets-thread.c. Your solution may use any Pthreads function. Your solution may not use the Unix sleep or alarm functions. Test your solution using the following driver program: code/threads/tfgets-main.c #include "csapp.h" char *tfgets(char *s, int size, FILE *stream); int main() { char buf[MAXLINE]; if (tfgets(buf, MAXLINE, stdin) == NULL) printf("BOOM!\n"); else printf("%s", buf); exit(0); } code/threads/tfgets-main.c Homework Problem 11.12 [Category 3]: For an interesting contrast in concurrency models, implement tfgets using processes, signals, and nonlocal jumps instead of threads. ¯ ¯ Your function should be implemented in a package called tfgets-proc.c. Your solution may not use the Unix alarm function. 11.8. SUMMARY 603 ¯ Test your solution using the driver program from Problem 11.11. 604 CHAPTER 11. CONCURRENT PROGRAMMING WITH THREADS Chapter 12 Network Programming...
View Full Document

Ask a homework question - tutors are online