Category : Files from Magazines
Archive   : PROGJRNL.ZIP
Filename : LISTING.4

 
Output of file : LISTING.4 contained in archive : PROGJRNL.ZIP
1 /*
2 * client.c ----- A potential customer for the background process
3 * (i.e., "daemon"). All it does is send a string
4 * and its process id to the daemon.
5 * Note that read() and write() are atomic,
6 * uninterruptable system calls. This guarantees
7 * that our data arrive in one piece and not
8 * interleaved with some other client's data.
9 */
10
11 #include
12 #include
13 #include
14 #include "local.h"
15
16 int fd; /* File descriptor for the Named Pipe (FIFO) */
17 PACKET msg; /* Information to be sent over a FIFO to a server process */
18
19 main(argc,argv)
20 char **argv;
21 {
22 int quit(); /* What to do when killed */
23
24 srand(getpid());
25
26 msg.pid = getpid(); /* Setup the data to be sent */
27 strcpy(msg.string, "Message from a Client");
28
29
30 /* Open the FIFO (Named Pipe) for writing */
31
32 if ( (fd = open(PIPE, O_WRONLY)) == -1 )
33 fprintf(stderr, "Cannot open PIPE in client\n"), exit(1);
34
35 signal(SIGINT, quit); /* Prepare for a Break */
36
37 while(1)
38 {
39 write(fd, &msg, sizeof msg); /* Write to server */
40
41 sleep(rand() % 10); /* Nice and slow, so we can see msgs */
42 }
43 }
44
45 /*****************************************************************************/
46
47 quit()
48 {
49 strcpy(msg.string, "Done"); /* Tell server to kill itself */
50 write(fd, &msg, sizeof msg);
51 exit(0); /* Kill this particular client */
52 }


  3 Responses to “Category : Files from Magazines
Archive   : PROGJRNL.ZIP
Filename : LISTING.4

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/