?? 15.7.c
字號:
#include <stdio.h>#include <netdb.h> int main(){ struct servent *ser; if( ser=getservbyname("ftp","tcp")) { printf("name : %s\n",ser->s_name); printf("port : %d ",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=getservbyname("http","tcp")) { printf("name : %s\n",ser->s_name); printf("port : %d ",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=getservbyname("asdasd","tcp")) { printf("name : %s\n",ser->s_name); printf("port : %d ",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 + -