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

全部博文(573)

文章存档

2018年(3)

2016年(48)

2015年(522)

分类: LINUX

2015-12-02 15:42:59


点击(此处)折叠或打开

  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("setservent 函数执行:\n");
  8.     setservent(1);
  9.     printf("000000**************************************\n");
  10.     struct servent * serv0 = NULL;
  11.     serv0 = getservent();
  12.     if(serv0 != NULL)
  13.     {
  14.         printf("s_name =[%s]\n", serv0->s_name);
  15.         printf("s_aliases[0]=[%s]\n", serv0->s_aliases[0]);
  16.         printf("s_port =[%d]\n", serv0->s_port);
  17.         printf("s_proto =[%d]\n", serv0->s_proto);
  18.     }
  19.     else
  20.     {
  21.         printf("serv0 is null\n");
  22.     }
  23.     
  24.     printf("111111**************************************\n");
  25.     struct servent * serv1 = NULL;
  26.     serv1 = getservent();
  27.     if(serv1 != NULL)
  28.     {
  29.         printf("s_name =[%s]\n", serv1->s_name);
  30.         printf("s_aliases[0]=[%s]\n", serv1->s_aliases[0]);
  31.         printf("s_port =[%d]\n", serv1->s_port);
  32.         printf("s_proto =[%d]\n", serv1->s_proto);
  33.     }
  34.     else
  35.     {
  36.         printf("serv1 is null\n");
  37.     }
  38.     
  39.     printf("222222**************************************\n");
  40.     struct servent * serv2 = NULL;
  41.     serv2 = getservent();
  42.     if(serv2 != NULL)
  43.     {
  44.         printf("s_name =[%s]\n", serv2->s_name);
  45.         printf("s_aliases[0]=[%s]\n", serv2->s_aliases[0]);
  46.         printf("s_port =[%d]\n", serv2->s_port);
  47.         printf("s_proto =[%d]\n", serv2->s_proto);
  48.     }
  49.     else
  50.     {
  51.         printf("serv2 is null\n");
  52.     }
  53.     
  54.     printf("333333**************************************\n");
  55.     struct servent * serv3 = NULL;
  56.     serv3 = getservent();
  57.     if(serv3 != NULL)
  58.     {
  59.         printf("s_name =[%s]\n", serv3->s_name);
  60.         printf("s_aliases[0]=[%s]\n", serv3->s_aliases[0]);
  61.         printf("s_port =[%d]\n", serv3->s_port);
  62.         printf("s_proto =[%d]\n", serv3->s_proto);
  63.     }
  64.     else
  65.     {
  66.         printf("serv3 is null\n");
  67.     }
  68.     
  69.     setservent(1);
  70.     printf("444444**************************************\n");
  71.     struct servent * serv4 = NULL;
  72.     serv4 = getservent();
  73.     if(serv4 != NULL)
  74.     {
  75.         printf("s_name =[%s]\n", serv4->s_name);
  76.         printf("s_aliases[0]=[%s]\n", serv4->s_aliases[0]);
  77.         printf("s_port =[%d]\n", serv4->s_port);
  78.         printf("s_proto =[%d]\n", serv4->s_proto);
  79.     }
  80.     else
  81.     {
  82.         printf("serv4 is null\n");
  83.     }
  84.     
  85.     printf("555555**************************************\n");
  86.     struct servent * serv5 = NULL;
  87.     serv5 = getservent();
  88.     if(serv5 != NULL)
  89.     {
  90.         printf("s_name =[%s]\n", serv5->s_name);
  91.         printf("s_aliases[0]=[%s]\n", serv5->s_aliases[0]);
  92.         printf("s_port =[%d]\n", serv5->s_port);
  93.         printf("s_proto =[%d]\n", serv5->s_proto);
  94.     }
  95.     else
  96.     {
  97.         printf("serv5 is null\n");
  98.     }
  99.     
  100.     printf("666666**************************************\n");
  101.     struct servent * serv6 = NULL;
  102.     serv6 = getservent();
  103.     if(serv6 != NULL)
  104.     {
  105.         printf("s_name =[%s]\n", serv6->s_name);
  106.         printf("s_aliases[0]=[%s]\n", serv6->s_aliases[0]);
  107.         printf("s_port =[%d]\n", serv6->s_port);
  108.         printf("s_proto =[%d]\n", serv6->s_proto);
  109.     }
  110.     else
  111.     {
  112.         printf("serv6 is null\n");
  113.     }
  114.     
  115.     printf("777777**************************************\n");
  116.     struct servent * serv7 = NULL;
  117.     serv7 = getservent();
  118.     if(serv7 != NULL)
  119.     {
  120.         printf("s_name =[%s]\n", serv7->s_name);
  121.         printf("s_aliases[0]=[%s]\n", serv7->s_aliases[0]);
  122.         printf("s_port =[%d]\n", serv7->s_port);
  123.         printf("s_proto =[%d]\n", serv7->s_proto);
  124.     }
  125.     else
  126.     {
  127.         printf("serv7 is null\n");
  128.     }
  129.     
  130. /*    while(1); */
  131.     
  132.     return 0;
  133. }

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

上一篇:getprotoent函数

下一篇:select函数

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