/* Copyright (c) 2001-2009 by SoftIntegration, Inc. All Rights Reserved */
/* a sample program that gets the ftp/tcp port number. */
#include <stdlib.h>
#include <stdio.h>
#include <netdb.h>
#include <netinet/in.h>

int main() {
    struct servent *sp;
    
    if((sp = getservbyname("ftp","tcp")) == NULL) {
        perror("getservbyname:\n");
        exit(1);
    }
    printf("%s\n",sp->s_name);  /* service name */
    printf("%d\n",sp->s_port);  /* port number */
}
