我正在向服务器发送 172.217.2.142\r\n
而它只回应:
# # ARIN的WHOIS数据和服务受使用条款的约束 # 可在: https:/www.arin.netwhois_tou.html # 如果你看到结果不准确,请在#报告。https:/www.arin.netpublicwhoisinaccuracyindex.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格式。