svc_tp_create()--Create a Server Handle


  Syntax

 #include <rpc/rpc.h>

 SVCXPRT svc_tp_create(const void
                 (*dispatch)(const svc_req *,
                      const SVCXPRT *),
                  const u_long prognum,
                  const u_long versnum,
                  const struct netconfig *netconf);

  Service Program Name: QZNFTRPC

  Default Public Authority: *USE

  Threadsafe: No

The svc_tp_create() function creates a server handle for the network specified by netconf, and registers itself with the RPC service package (RPCBind).


Parameters

dispatch()  (Input) 
The server dispatch function. dispatch() is called when there is a remote procedure call for the given prognum and versnum. The call to dispatch requires calling svc_run() on the server side.

prognum  (Input) 
The program number of the remote program.

vernum  (Input) 
The version number of the remote program.

netconf  (Input) 
The transport protocol to use.

Authorities

No authorization is needed.


Return Value

xprt Upon successful completion, this function returns the service handle.
NULL svc_tp_create() was not successful. The errno variable is set to indicate the reason.


Error Conditions

This API calls svc_tli_create() and svc_reg() functions in order to perform its task. It inherits all error conditions from those functions, except setnetconfig() and getnetconfig() errors and RPC_UNKNOWNADDR from svc_reg().


Error Messages

Message ID Error Message Text
CPIA1B1 I A problem was encountered in the RPC client.
CPIA1B2 I TI-RPC encountered a problem in the transport protocol.
CPIA1B3 I TI-RPC encountered a problem in the server.
CPIA1B8 I A problem occurred while trying to contact the RPCBind daemon.
CPE3418 E Possible APAR condition or hardware failure.
CPF3CF2 E Error(s) occurred during running of &1 API.
CPF9872 E Program or service program &1 in library &2 ended. Reason code &3.


Related Information


Example

The following example shows how svc_tp_create() is used.

Note: By using the code examples, you agree to the terms of the Code license and disclaimer information.

/* Define remote program number and version */
#define RMTPROGNUM (u_long)0x3fffffffL
#define RMTPROGVER (u_long)0x1

#include <stdio.h>
#include <rpc/rpc.h>
#include <netconfig.h>

static void exm_proc();
/* Dispatcher routine, defined later in program */

main()
{
  SVCXPRT *transp;
  struct netconfig *nconf;

  /* Returns a pointer to nconf corresponding to UDP */
  if ((nconf = getnetconfigent("UDP")) ==
               (struct netconfig *)NULL) {
    fprintf(stderr, "Cannot get netconfig entry for UDP\n");
    exit(1);
  }

  transp = svc_tp_create(exm_proc, RMTPROGNUM, RMTPROGVER,
                                    nconf);
  if (transp == (SVCXPRT *)NULL) {
    fprintf(stderr, "Cannot create service.\n");
    exit(1);
  }

  ...
  svc_run();
}

/* The server dispatch function */
static void exm_proc(struct svc_req *rqstp, SVCXPRT *transp)
{

  ...

}



API introduced: V4R2

[ Back to top | Remote Procedure Call (RPC) APIs | APIs by category ]