- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
见鬼去吧。我正在做一个服务器 c 项目,使用 UDP 提供 whois 服务。但是我收到错误消息:“此主机上没有 whois 服务。”这是我的代码:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <pwd.h>
#define BACKLOG 5 /* # of requests we're willing to queue */
#define MAXHOSTNAME 32 /* maximum host name length we tolerate */
main(argc,argv)
int argc; /* standard UNIX argument declarations */
char *argv[];
{
int s,t; /* socket descriptors */
int i; /* general purpose integer */
struct sockaddr_in sa,isa; /* Internet socket address structure */
struct hostent *hp; /* result of host name lookup */
char *myname; /* pointer to name of this program */
struct servent *sp; /* result of service lookup */
char localhost[MAXHOSTNAME+1]; /* local host name as character string */
myname = argv[0];
/*
* Look up the WHOIS service entry
*/
if((sp = getservbyname("whois","udp")) == NULL){
fprintf(stderr, "%s: No whois service on this host\n", myname);
exit(1);
}
/*
* Get our own host information
*/
gethostname(localhost, MAXHOSTNAME);
if((hp = gethostbyname(localhost)) == NULL){
fprintf(stderr, "%s: cannot get local host info?\n", myname);
exit(1);
}
printf("host name is: %s\n",hp->h_name);
printf("my name is: %s\n",myname);
/*
* Put the WHOIS socket number and our address info into the socket structure
*/
u_short portbase = 0;
portbase = 5000;
sa.sin_port = sp->s_port;
sa.sin_port = htons(ntohs((u_short)sp->s_port)+portbase);
bcopy((char *)hp->h_addr, (char *)&sa.sin_addr, hp->h_length);
sa.sin_family = hp->h_addrtype;
/*
* Allocate an open socket for incoming connections
*/
if((s = socket(hp->h_addrtype, SOCK_DGRAM, 0)) < 0){
perror("socket");
exit(1);
}
/*
* Bind the socket to the service port
*/
if(bind(s, (struct sockaddr *)&sa, sizeof sa) < 0){
perror("bind");
exit(1);
}
/*
* Set maximum connections we will fall behind
*/
//listen(s,BACKLOG);
/*
* Go into an infinite loop waiting for new connections
*/
while(1){
i = sizeof isa;
/*
* We hang in accept() while waiting for new customers
*/
/*
if((t = accept(s, (struct sockaddr *)&isa, &i)) < 0){
perror("accept");
exit(1);
}
*/
whois(s); /* perform the actual WHOIS service */
close(s);
}
}
/*
* Get the WHOIS request from remote host and format a reply.
*/
whois(sock)
int sock;
{
struct sockaddr_in clientAddr;
socklen_t len = sizeof(clientAddr);
memset(&clientAddr, 0, sizeof(clientAddr));
struct passwd *p;
char buf[BUFSIZ+1];
int i;
/*
* Get one line request
*/
printf("start to recv data\n");
if((i = recvfrom(sock, buf, BUFSIZ, 0, (struct sockaddr*)&clientAddr, &len)) <= 0)
printf("recv failed\n");
return;
buf[i] = '\0'; /* Null terminate */
printf("After the read, the buf is: %s \n",buf);
/*
* Look up the requested user and format reply
*/
if((p = getpwnam(buf)) == NULL)
strcpy(buf, "User not found\n");
else
sprintf(buf, "%s: %s (from me)\n", p->pw_name, p->pw_gecos);
/*
* Return reply
*/
//write(sock, buf, strlen(buf));
sendto(sock, buf, strlen(buf), 0, (struct sockaddr*)&clientAddr, len);
return;
}
我不知道哪里出错了。我有一个类似的代码,使用 TCP for whois 运行没有问题。
最佳答案
WHOIS 是一项 TCP 服务。它在 UDP 上不可用。
此外,您所写的根本不是 WHOIS 服务器。 WHOIS 是由域和 IP 注册商实现的协议(protocol),用于传达所有权信息(例如,查找域名的所有者)。您在这里写的似乎是某种 NIS 服务 - 这不是 WHOIS,不应使用相同的端口。
关于c - 使用 UDP 的 Whois 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19498241/
我正在尝试制作一个桌面应用程序来检查 whois 记录以及其他内容,并且我发现了一些将顶级域映射到 whois 服务器的列表。它们通常工作,但有时必须在不同的 whois 服务器上找到信息。例如,而
我正在监视域的到期时间。熟悉域名过期流程:宽限期,赎回期,然后删除。 让我感到困惑的是,当我在任何 WhoIs 数据库(NetworkSolution、ICANN 等)中搜索此特定域时。结果是: No
我想从 IANA 的 whois 服务器获取所有国家的 ip 地址范围,而不是从 maxmind 或 ip2location 站点。 IANA 是真实站点,因此我想从该站点获取国家/地区的所有 ipa
我正在使用 WHOIS API 来获取有关注册域名的公司的信息。但是,我不想要通过代理注册域的结果,例如“Domains By Proxy”。 是否有一个全面的或其他体面的提供者列表可以放入我的代码中
我尝试将域名 sans.org 设为 WHOIS,但出现以下错误: getaddrinfo(whois.pir.org): Name or service not known. 然后我尝试到 WHOI
我正在用 Ruby 编写一个简单的程序来检查域列表是否被占用。基本上它循环遍历列表,并使用以下函数进行检查。 require 'rubygems' require 'whois' def check_
我正在尝试获取域名的 whois 数据,所有其他域(.com 和 .net 除外)都给出了一些域名信息结果,但在查询 .com 和 .net 注册表的 whois 服务器时。 (whois.veris
我想做的是使用 netstat -an | grep ESTABLISHED 从 whois 搜索中检查我系统中的所有 IP 地址,并禁止任何属于中国的 IP 地址。 所以我想知道如何实现这一目标?可
我有一个域名文件,例如相当于2500。 我想对这些域名进行 whois。 问题是我从来没有这样做过,也不知道从哪里开始。如果您有任何想法,我会全神贯注。 TIA。 最佳答案 您还可以使用 Linux
如今,无论何时使用 WHOIS 命令都不会返回任何有用的信息。我通常必须去Godaddy、Dnsstuff或其他服务来获取数据。我知道原因主要是垃圾邮件。 我只是想知道其他服务如何获取这些数据。他们是
我有一个问题,我想使用套接字通过端口43连接到whois服务器,但似乎不可能或我做错了。我已经测试过socketio和jsXMLsocket,但是没有运气。 使用PHP可以通过使用 fsockopen
我正在发送服务器 172.217.2.142\r\n 并且它只响应: # # ARIN WHOIS data and services are subject to the Terms of Use
嗨,我一直在弄乱我从网上获得的这个 Whois 脚本,并且一直在弄乱变量和数组,一直试图弄清楚为什么它不会返回 Google 和 Facebook 的 whois 结果(我测试了谷歌,因为这是显而易见
嗨,我一直在弄乱我从网上获得的这个 Whois 脚本,并且一直在弄乱变量和数组,一直试图弄清楚为什么它不会返回 Google 和 Facebook 的 whois 结果(我测试了谷歌,因为这是显而易见
例如,我正在尝试找到对应的 whois 服务器的 TLD 列表 .com americanWhoisServer.net someOtherWhoisServer.au australianWhois
作为一个自学项目,我正在实现一个 C++ whois 客户端。我正在使用几个古老的 C 实现作为引用,例如koders.com . 有一件事让我很困惑。除了预期的路径格式,如 example.com、
我正在使用位于 http://ruby-whois.org 的 Ruby Whois gem自动检索各种网站的 Whois 记录。 目前,我每天执行几千次查询。我注意到我进行的许多查询会导致超时错误或
是否有任何 WHOIS 服务器守护程序可在我的服务器上运行并满足我的请求? 是否可以像 DNS 服务器一样在 WHOIS 层次结构的末端部署自己的 WHOIS 服务器? 最佳答案 看看rwhois .
我正在编写一些分析注册域名并寻找趋势的软件。我正在尝试一些机器学习,以帮助根据正在注册的域类型来预测 future 将购买哪些域名。 我一直在寻找一种方法来下载存在的“所有”已注册域,但我一直找不到这
关闭。这个问题是off-topic .它目前不接受答案。 想改善这个问题吗? Update the question所以它是 on-topic对于堆栈溢出。 12 年前关闭。 Improve this
我是一名优秀的程序员,十分优秀!