Adding a new service to the server code involves writing the function to be called when your service is invoked and adding the service name in the main module. The following example shows how to add a service called ``howdy''.
To add the service name in the main module edit the file nlrexecd.c.
char *howdy();
"howdy",
howdy,
Notice that the position of "howdy" in service_list should correspond to the position of howdy in service_call.
#include <stdio.h> #include "nlrexecd.h" char *howdy(s, service, extra) int s ; char *service, *extra; { swrite(s, "hello world\n"); return "howdy ok"; }
The string returned by a service function is written to the log file.
Now type make.
To test your new service start the server and use telnet to talk to it.
csh> telnet localhost 5555 Trying... Connected to localhost Escape character is '^]'. wade@cs.utk.edu -- you type this howdy -- and this nothing -- and this hello world Connection closed. csh>