getserv.c
资源名称:socks5.zip [点击查看]
上传用户:sddyfurun
上传日期:2007-01-04
资源大小:525k
文件大小:1k
源码类别:
代理服务器
开发平台:
Unix_Linux
- #include <stdio.h>
- #include <sys/types.h>
- #include <netinet/in.h>
- #include <netdb.h>
- static char *servname = "finger";
- static char *hostname = "ftp.uu.net";
- int main(int argc, char **argv) {
- struct servent *sp;
- struct hostent *hp;
- fprintf(stderr, "Hin");
- if (argc > 1) servname = argv[1];
- if (argc > 2) servname = argv[2];
- if ((sp = getservbyname(servname, "tcp")) == NULL) {
- fprintf(stderr, "Unable to resolve service name: %sn", servname);
- exit(-1);
- }
- fprintf(stderr, "Hi againn");
- hp = gethostbyname(hostname);
- if (strcmp(sp->s_name, servname)) {
- fprintf(stderr, "Test failed, gethostbyname clobbered service name: %s -> %sn", servname, sp->s_name);
- exit(-1);
- }
- fprintf(stderr, "Test succeeded, gethostbyname didn't change a thingn");
- exit(0);
- }