📄 15.8.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 + -