7 static char *rcsid_tfsr_c = "$Header$";
10 /************************************************************************/
12 /* tfsr (test forking server)
13 /* --------------------------
15 /* Author: Noah Mendelsohn (IBM T.J. Watson Research and MIT Project
18 /* Copyright: 1986 MIT Project Athena
20 /************************************************************************/
25 /* A GDB server program demonstrating techniques for asynchronously
26 /* communicating with an arbitrary number of clients by forking
27 /* a new server process for each incoming client.
29 /* Each forked child receives a stream of integers,
30 /* which it interprets as ASCII characters. The characters are
31 /* converted to uppercase, and then sent back to the client from
37 /* This program is interface compatible with tsr.c. Clients
38 /* cannot tell which style of server they are using.
40 /************************************************************************/
51 /*----------------------------------------------------------*/
55 /*----------------------------------------------------------*/
57 CONNECTION client; /* talk on this to client */
59 int data; /* receive data here */
61 \f /*----------------------------------------------------------*/
63 /* EXECUTION BEGINS HERE
67 /*----------------------------------------------------------*/
70 fprintf(stderr,"Correct form is %s <servicename>\n",
75 /*----------------------------------------------------------*/
79 /*----------------------------------------------------------*/
81 gdb_init(); /* set up gdb */
83 /*----------------------------------------------------------*/
85 /* Now, turn ourselves into a forking server.
87 /*----------------------------------------------------------*/
89 client = create_forking_server(argv[1],NULL);
90 fprintf(stderr,"forked\n");
92 /*----------------------------------------------------------*/
94 /* Here we are in the child process for each client.
95 /* Echo the characters.
97 /*----------------------------------------------------------*/
100 if (receive_object(client, &data, INTEGER_T) ==
102 fprintf(stderr,"receive error\n");
105 if (data >= 'a' && data <= 'z')
106 data += 'A'-'a'; /* upcase the response */
107 if (send_object(client, &data, INTEGER_T) ==
109 fprintf(stderr,"send error\n");