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

int main() {
    struct protoent *protocol;
    char * name = "udp";

    protocol = getprotobyname(name);
    if(protocol == NULL)  {
      printf("Cannot get protocol udp by getprotobyname\n");
      exit(1);
    }
    printf("%s\n",protocol->p_name); /* protocol name */
    printf("%d\n",protocol->p_proto);  /*protocol number */
    printf("%s\n",protocol->p_aliases[0]); /*protocol aliases */
}
