Back to index

glibc  2.9
getrpcport.c File Reference
#include <alloca.h>
#include <errno.h>
#include <stdio.h>
#include <netdb.h>
#include <string.h>
#include <rpc/rpc.h>
#include <rpc/clnt.h>
#include <rpc/pmap_clnt.h>
#include <sys/socket.h>

Go to the source code of this file.


int getrpcport (const char *host, u_long prognum, u_long versnum, u_int proto)

Function Documentation

int getrpcport ( const char *  host,
u_long  prognum,
u_long  versnum,
u_int  proto 

Definition at line 49 of file getrpcport.c.

  struct sockaddr_in addr;
  struct hostent hostbuf, *hp;
  size_t buflen;
  char *buffer;
  int herr;

  buflen = 1024;
  buffer = __alloca (buflen);
  while (__gethostbyname_r (host, &hostbuf, buffer, buflen, &hp, &herr) != 0
        || hp == NULL)
    if (herr != NETDB_INTERNAL || errno != ERANGE)
      return 0;
       /* Enlarge the buffer.  */
       buflen *= 2;
       buffer = __alloca (buflen);

  memcpy ((char *) &addr.sin_addr, hp->h_addr, hp->h_length);
  addr.sin_family = AF_INET;
  addr.sin_port = 0;
  return pmap_getport (&addr, prognum, versnum, proto);

Here is the call graph for this function: