Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1184921
  • 博文数量: 573
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 66
  • 用 户 组: 普通用户
  • 注册时间: 2016-06-28 16:21
文章分类

全部博文(573)

文章存档

2018年(3)

2016年(48)

2015年(522)

分类: LINUX

2015-12-02 15:41:14


点击(此处)折叠或打开

  1. #include <string.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <netdb.h>

  5. int main(int argc, char * * argv)
  6. {
  7.     printf("setprotoent 函数执行:\n");
  8.     setprotoent(1);
  9.     printf("000000**************************************\n");
  10.     struct protoent * proto0 = NULL;
  11.     proto0 = getprotoent();
  12.     if(proto0 != NULL)
  13.     {
  14.         printf("p_name =[%s]\n", proto0->p_name);
  15.         printf("p_aliases[0]=[%s]\n", proto0->p_aliases[0]);
  16.         printf("p_proto =[%d]\n", proto0->p_proto);
  17.     }
  18.     else
  19.     {
  20.         printf("proto0 is null\n");
  21.     }
  22.     
  23.     printf("111111**************************************\n");
  24.     struct protoent * proto1 = NULL;
  25.     proto1 = getprotoent();
  26.     if(proto1 != NULL)
  27.     {
  28.         printf("p_name =[%s]\n", proto1->p_name);
  29.         printf("p_aliases[0]=[%s]\n", proto1->p_aliases[0]);
  30.         printf("p_proto =[%d]\n", proto1->p_proto);
  31.     }
  32.     else
  33.     {
  34.         printf("proto1 is null\n");
  35.     }
  36.     
  37.     printf("222222**************************************\n");
  38.     struct protoent * proto2 = NULL;
  39.     proto2 = getprotoent();
  40.     if(proto2 != NULL)
  41.     {
  42.         printf("p_name =[%s]\n", proto2->p_name);
  43.         printf("p_aliases[0]=[%s]\n", proto2->p_aliases[0]);
  44.         printf("p_proto =[%d]\n", proto2->p_proto);
  45.     }
  46.     else
  47.     {
  48.         printf("proto2 is null\n");
  49.     }
  50.     
  51.     printf("333333**************************************\n");
  52.     struct protoent * proto3 = NULL;
  53.     proto3 = getprotoent();
  54.     if(proto3 != NULL)
  55.     {
  56.         printf("p_name =[%s]\n", proto3->p_name);
  57.         printf("p_aliases[0]=[%s]\n", proto3->p_aliases[0]);
  58.         printf("p_proto =[%d]\n", proto3->p_proto);
  59.     }
  60.     else
  61.     {
  62.         printf("proto3 is null\n");
  63.     }
  64.     
  65.     printf("444444**************************************\n");
  66.     struct protoent * proto4 = NULL;
  67.     proto4 = getprotoent();
  68.     if(proto4 != NULL)
  69.     {
  70.         printf("p_name =[%s]\n", proto4->p_name);
  71.         printf("p_aliases[0]=[%s]\n", proto4->p_aliases[0]);
  72.         printf("p_proto =[%d]\n", proto4->p_proto);
  73.     }
  74.     else
  75.     {
  76.         printf("proto4 is null\n");
  77.     }
  78.     
  79.     printf("555555**************************************\n");
  80.     struct protoent * proto5 = NULL;
  81.     proto5 = getprotoent();
  82.     if(proto5 != NULL)
  83.     {
  84.         printf("p_name =[%s]\n", proto5->p_name);
  85.         printf("p_aliases[0]=[%s]\n", proto5->p_aliases[0]);
  86.         printf("p_proto =[%d]\n", proto5->p_proto);
  87.     }
  88.     else
  89.     {
  90.         printf("proto5 is null\n");
  91.     }
  92.     
  93.     printf("666666**************************************\n");
  94.     struct protoent * proto6 = NULL;
  95.     proto6 = getprotoent();
  96.     if(proto6 != NULL)
  97.     {
  98.         printf("p_name =[%s]\n", proto6->p_name);
  99.         printf("p_aliases[0]=[%s]\n", proto6->p_aliases[0]);
  100.         printf("p_proto =[%d]\n", proto6->p_proto);
  101.     }
  102.     else
  103.     {
  104.         printf("proto6 is null\n");
  105.     }
  106.     
  107.     printf("777777**************************************\n");
  108.     struct protoent * proto7 = NULL;
  109.     proto7 = getprotoent();
  110.     if(proto7 != NULL)
  111.     {
  112.         printf("p_name =[%s]\n", proto7->p_name);
  113.         printf("p_aliases[0]=[%s]\n", proto7->p_aliases[0]);
  114.         printf("p_proto =[%d]\n", proto7->p_proto);
  115.     }
  116.     else
  117.     {
  118.         printf("proto7 is null\n");
  119.     }
  120.     
  121.     printf("888888**************************************\n");
  122.     struct protoent * proto8 = NULL;
  123.     proto8 = getprotoent();
  124.     if(proto8 != NULL)
  125.     {
  126.         printf("p_name =[%s]\n", proto8->p_name);
  127.         printf("p_aliases[0]=[%s]\n", proto8->p_aliases[0]);
  128.         printf("p_proto =[%d]\n", proto8->p_proto);
  129.     }
  130.     else
  131.     {
  132.         printf("proto8 is null\n");
  133.     }
  134.     
  135.     printf("999999**************************************\n");
  136.     struct protoent * proto9 = NULL;
  137.     proto9 = getprotoent();
  138.     if(proto7 != NULL)
  139.     {
  140.         printf("p_name =[%s]\n", proto9->p_name);
  141.         printf("p_aliases[0]=[%s]\n", proto9->p_aliases[0]);
  142.         printf("p_proto =[%d]\n", proto9->p_proto);
  143.     }
  144.     else
  145.     {
  146.         printf("proto9 is null\n");
  147.     }
  148.     
  149.     printf("10.10**************************************\n");
  150.     struct protoent * proto10 = NULL;
  151.     proto10 = getprotoent();
  152.     if(proto10 != NULL)
  153.     {
  154.         printf("p_name =[%s]\n", proto10->p_name);
  155.         printf("p_aliases[0]=[%s]\n", proto10->p_aliases[0]);
  156.         printf("p_proto =[%d]\n", proto10->p_proto);
  157.     }
  158.     else
  159.     {
  160.         printf("proto10 is null\n");
  161.     }
  162.     
  163.     printf("11.11**************************************\n");
  164.     struct protoent * proto11 = NULL;
  165.     proto11 = getprotoent();
  166.     if(proto11 != NULL)
  167.     {
  168.         printf("p_name =[%s]\n", proto11->p_name);
  169.         printf("p_aliases[0]=[%s]\n", proto11->p_aliases[0]);
  170.         printf("p_proto =[%d]\n", proto11->p_proto);
  171.     }
  172.     else
  173.     {
  174.         printf("proto11 is null\n");
  175.     }
  176.     
  177.     printf("12.12**************************************\n");
  178.     struct protoent * proto12 = NULL;
  179.     proto12 = getprotoent();
  180.     if(proto12 != NULL)
  181.     {
  182.         printf("p_name =[%s]\n", proto12->p_name);
  183.         printf("p_aliases[0]=[%s]\n", proto12->p_aliases[0]);
  184.         printf("p_proto =[%d]\n", proto12->p_proto);
  185.     }
  186.     else
  187.     {
  188.         printf("proto12 is null\n");
  189.     }
  190.     
  191.     printf("13.13**************************************\n");
  192.     struct protoent * proto13 = NULL;
  193.     proto13 = getprotobyname("BBN-RCC-MON");
  194.     if(proto13 != NULL)
  195.     {
  196.         printf("p_name =[%s]\n", proto13->p_name);
  197.         printf("p_aliases[0]=[%s]\n", proto13->p_aliases[0]);
  198.         printf("p_proto =[%d]\n", proto13->p_proto);
  199.     }
  200.     else
  201.     {
  202.         printf("proto13 is null\n");
  203.     }
  204.     
  205.     printf("14.14**************************************\n");
  206.     struct protoent * proto14 = NULL;
  207.     proto14 = getprotobynumber(proto13->p_proto);
  208.     if(proto14 != NULL)
  209.     {
  210.         printf("p_name =[%s]\n", proto14->p_name);
  211.         printf("p_aliases[0]=[%s]\n", proto14->p_aliases[0]);
  212.         printf("p_proto =[%d]\n", proto14->p_proto);
  213.     }
  214.     else
  215.     {
  216.         printf("proto14 is null\n");
  217.     }
  218.     
  219.     printf("15.15**************************************\n");
  220.     struct protoent * proto15 = NULL;
  221.     proto15 = getprotobynumber(0);
  222.     if(proto15 != NULL)
  223.     {
  224.         printf("p_name =[%s]\n", proto15->p_name);
  225.         printf("p_aliases[0]=[%s]\n", proto15->p_aliases[0]);
  226.         printf("p_proto =[%d]\n", proto15->p_proto);
  227.     }
  228.     else
  229.     {
  230.         printf("proto15 is null\n");
  231.     }
  232.     
  233.     printf("16.16**************************************\n");
  234.     struct protoent * proto16 = NULL;
  235.     proto16 = getprotobynumber(1);
  236.     if(proto16 != NULL)
  237.     {
  238.         printf("p_name =[%s]\n", proto16->p_name);
  239.         printf("p_aliases[0]=[%s]\n", proto16->p_aliases[0]);
  240.         printf("p_proto =[%d]\n", proto16->p_proto);
  241.     }
  242.     else
  243.     {
  244.         printf("proto16 is null\n");
  245.     }
  246.     
  247.     printf("17.17**************************************\n");
  248.     struct protoent * proto17 = NULL;
  249.     proto17 = getprotobyname("hopopt");
  250.     if(proto17 != NULL)
  251.     {
  252.         printf("p_name =[%s]\n", proto17->p_name);
  253.         printf("p_aliases[0]=[%s]\n", proto17->p_aliases[0]);
  254.         printf("p_proto =[%d]\n", proto17->p_proto);
  255.     }
  256.     else
  257.     {
  258.         printf("proto17 is null\n");
  259.     }
  260.     
  261.     printf("18.18**************************************\n");
  262.     struct protoent * proto18 = NULL;
  263.     proto18 = getprotobyname("IP");
  264.     if(proto18 != NULL)
  265.     {
  266.         printf("p_name =[%s]\n", proto18->p_name);
  267.         printf("p_aliases[0]=[%s]\n", proto18->p_aliases[0]);
  268.         printf("p_proto =[%d]\n", proto18->p_proto);
  269.     }
  270.     else
  271.     {
  272.         printf("proto18 is null\n");
  273.     }
  274.     
  275.     return 0;
  276. }

阅读(421) | 评论(0) | 转发(0) |
0

上一篇:poll函数

下一篇:getservent函数

给主人留下些什么吧!~~