⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 15.8.c

📁 该程序包详细讲述了Linux环境下的Socket编程
💻 C
字号:
#include <stdio.h>#include <netdb.h>   int  main(){    struct servent *ser;       if( ser=getservbyport(htons(23),"tcp"))    {       printf("name : %s\n",ser->s_name);       printf("port : %d\n",ntohs(ser->s_port));       printf("protocol:%s\n",ser->s_proto);       printf("alias: %s\n",ser->s_aliases[0]);    }    else    {    	printf("there is no such a service.\n");    }       if( ser=getservbyport(htons(80),"tcp"))    {       printf("name : %s\n",ser->s_name);       printf("port : %d\n",ntohs(ser->s_port));       printf("protocol:%s\n",ser->s_proto);       printf("alias: %s\n",ser->s_aliases[0]);    }    else    {    	printf("there is no such a service.\n");    }        if( ser=getservbyport(htons(61111),"tcp"))    {       printf("name : %s\n",ser->s_name);       printf("port : %d\n",ntohs(ser->s_port));       printf("protocol:%s\n",ser->s_proto);       printf("alias: %s\n",ser->s_aliases[0]);    }    else    {    	printf("there is no such a service.\n");    } }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -