/* Copyright (c) 2001-2009 by SoftIntegration, Inc. All Rights Reserved */
/* a sample program that prints the name of protocol. */
#include <stdlib.h>
#include <stdio.h>
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>

int main() {
    struct protoent result;
    int proto = 17;  /* udp number */
    char buffer[128];

    getprotobynumber_r(proto,&result,buffer,128);
    printf("%s\n",result.p_name); /* protocol name */
    printf("%d\n",result.p_proto);  /*protocol number */
    printf("%s\n",result.p_aliases[0]); /*protocol aliases */
}
 