Vb.net TcpClient错误

时间:2017-05-30 13:43:16

标签: sockets tcpclient whois

我正在尝试在vb.net中获取whois信息

我找到了一个代码

Private Function whoiscek(ByVal whoisServer As String, ByVal url As String) As String
    Dim stringBuilderResult As StringBuilder = New StringBuilder()
    Dim tcpClinetWhois As TcpClient = New TcpClient(whoisServer, 43)
    Dim networkStreamWhois As NetworkStream = tcpClinetWhois.GetStream()
    Dim bufferedStreamWhois As BufferedStream = New BufferedStream(networkStreamWhois)
    Dim streamWriter As StreamWriter = New StreamWriter(bufferedStreamWhois)

    streamWriter.WriteLine(url)
    streamWriter.Flush()

    Dim streamReaderReceive As StreamReader = New StreamReader(bufferedStreamWhois)

    While Not streamReaderReceive.EndOfStream
        stringBuilderResult.AppendLine(streamReaderReceive.ReadLine())
    End While

    Return stringBuilderResult.ToString()
End Function

但我收到了一个错误。 Error

[Errno 10061]无法建立连接,因为目标计算机主动拒绝了

如何解决错误?

0 个答案:

没有答案