Next: Reserved Service Names Up: Services and Protocol Previous: Services and Protocol

Adding a Service to Nlrexecd

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.

  1. Declare your function (which should return a char*) where the other service functions are declared.

    char *howdy();

  2. Add the name of your service to the service_list structure.

    "howdy",

  3. Add the name of your function to the service_call structure.

    howdy,

    Notice that the position of "howdy" in service_list should correspond to the position of howdy in service_call.

  4. Create a new file called howdy.c. It should look something like this.

    
    #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.

  5. Add howdy.o to OBJS in the Makefile.

    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>


browne@utkcs.cs.utk.edu
Thu Aug 25 09:07:23 EDT 1994