Purpose
Creates a User Datagram Protocol/Internet Protocol (UDP/IP) client transport handle.
Library
C Library (libc.a)
Syntax
#include <rpc/rpc.h>
  CLIENT *clntudp_create (addr, prognum, versnum, wait, sockp)
struct sockaddr_in * addr;
u_long  prognum,  versnum;
struct timeval  wait;
int * sockp;
Description
The clntudp_create subroutine creates a Remote Procedure Call (RPC) client transport handle for a remote program. The client uses UDP as the transport to pass messages to the service.
RPC messages transported by UDP/IP can hold up to 8KB of encoded data. Use this subroutine for procedures that take arguments or return results of less than 8KB.
Parameters
| Item | Description | 
|---|---|
| addr | Points to the Internet address of the remote program. If the port number for this Internet address (addr->sin_port) is 0, then the value of the addr parameter is set to the port that the remote program is listening on. The clntudp_create subroutine consults the remote portmap daemon for this information. | 
| prognum | Specifies the program number of the remote program. | 
| versnum | Specifies the version number of the remote program. | 
| wait | Sets the amount of time that the UDP/IP transport waits to receive a response before the transport sends another remote procedure call or the remote procedure call times out. The total time for the call to time out is set by the clnt_call macro. | 
| sockp | Specifies a pointer to a socket. If the value of the sockp parameter is RPC_ANYSOCK, the clntudp_create subroutine opens a new socket and sets the sockp pointer to that new socket. | 
Return Values
Upon successful completion, this subroutine returns a valid UDP client handle. If unsuccessful, it returns a value of null.
Purpose
Creates a User Datagram Protocol/Internet Protocol (UDP/IP) client transport handle.
Library
Network Services Library (libnsl.a)
Syntax
#include <rpc/rpc.h>
 CLIENT *clntudp_bufcreate (addr, prognum, versnum, wait, fdp)
struct sockaddr_in *addr;
rpcprog_t prognum;
rpcvers_t versnum;
struct timeval wait;
int *fdp;
Description
The clntudp_create subroutine creates a Remote Procedure Call (RPC) client transport handle for a remote program. The client uses UDP as the transport to pass messages to the service.
RPC messages transported by UDP/IP can hold up to 8KB of encoded data. Use this subroutine for procedures that take arguments or return results of less than 8KB.
Parameters
| Item | Description | 
|---|---|
| addr | Points to the Internet address of the remote program. If the port number for this Internet address (addr->sin_port) is 0, then the value of the addr parameter is set to the port that the remote program is listening on. The clntudp_create subroutine consults the remote portmap daemon for this information. | 
| prognum | Specifies the program number of the remote program. | 
| versnum | Specifies the version number of the remote program. | 
| wait | Sets the amount of time that the UDP/IP transport waits to receive a response before the transport sends another remote procedure call or the remote procedure call times out. The total time for the call to time out is set by the clnt_call macro. | 
| fdp | Specifies a pointer to a socket. If the value of the fdp parameter is RPC_ANYSOCK, the clnttcp_create subroutine opens a new socket and sets the fdp pointer to the new socket. | 
Return Values
| Item | Description | 
|---|---|
| a valid UDP client handle | successful | 
| a null value | unsuccessful | 
Error Codes
| Item | Description | 
|---|---|
| RPC_PROGNOTREGISTERED | The program is not registered. | 
| RPC_SYSTEMERROR | The file descriptor is not valid. | 
Examples
In the following example, the clntudp_create subroutine creates and returns a UDP/IP client transport handle.
#include <rpc/rpc.h>
#include <stdio.h>
#define ADDRBUFSIZE 255
#define ADDRBUFSIZE 255
int main()
{
  CLIENT *clnt;
  rpcprog_tPROGNUM = 0x3fffffffL;
  rpcvers_tPROGVER = 0x1L;
  intfd;
  struct timeval waittime = {25,0};
  struct sockaddr_in addr;
  char     addrbuf[ADDRBUFSIZE];
  struct netbuf   svcaddr;
  struct netconfig *nconf;
  char host[255] ; /* The remote host name */
  svcaddr.len = 0;
  svcaddr.maxlen = ADDRBUFSIZE;
  svcaddr.buf = addrbuf;
  /* Get pointer to struct netconfig for tcp transport */
  nconf = getnetconfigent("udp");
  if (nconf == (struct netconfig *) NULL) {
    printf("getnetconfigent() failed\n");
    exit(1);
  }
  /* Get the address of remote service */
  if (!rpcb_getaddr(PROGNUM, PROGVER, nconf, &svcaddr, host)) {
    printf("rpcb_getaddr() failed\n");
    exit(1);
  }
  memcpy(&addr, svcaddr.buf, sizeof(struct sockaddr_in));
  fd = ... /*Code to obtain open and bound file descriptor on udp transport */
  clnt = (CLIENT *) clntudp_create(&addr, PROGNUM, PROGVER, waittime, &fd);
  /*
   * Make a call to clnt_call() subroutine
   */
  /* Destroy the client handle in the end */
  clnt_destroy(clnt);
  return 0;
}