gpt4 book ai didi

C# - WHOIS 服务器提前关闭连接或不将整个响应发送到我的套接字?

转载 作者:行者123 更新时间:2023-12-03 11:50:13 25 4
gpt4 key购买 nike

我正在发送服务器 172.217.2.142\r\n 并且它只响应:

#
# ARIN WHOIS data and services are subject to the Terms of Use
# available at: https://www.arin.net/whois_tou.html
#
# If you see inaccuracies in the results, please report at
# https://www.arin.net/public/whoisinaccuracy/index.xhtml
#

我的接收函数:

private string getResponse(Socket sock)
{
byte[] buffer = new byte[1024];
string result = string.Empty;
int bytesReceived = 0;

do
{
bytesReceived = sock.Receive(buffer, 0, buffer.Length, SocketFlags.None);
Debug.Print("Bytes read:" + bytesReceived.ToString());
result += Encoding.ASCII.GetString(buffer);
Array.Clear(buffer, 0, buffer.Length);
} while (bytesReceived > 0);

return result;
}

最佳答案

一种流行的方法是使用 WebClient 从 URL 加载数据:

using (WebClient client = new WebClient())
{
string value = client.DownloadString("url");
}

返回的值是 arin.net 的 JSON 格式。

关于C# - WHOIS 服务器提前关闭连接或不将整个响应发送到我的套接字?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36725696/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com