0

我正在尝试使用 tcpclient 将消息发送到具有提供端口的远程服务器。在我的代码中,我看到连接成功并且正在发送消息,但是另一端的开发人员通知我没有收到任何消息。反正有调试这个吗?

 Public Sub New(ip As String, port As Integer)
    _GLOIP = IPAddress.Parse(ip)
    _port = port
    'initiate the client and get the stream to use
    myTcp = initiate()
    netStream = myTcp.GetStream()
End Sub
Public Sub send(text As String, ByRef err As String)
    If netStream.CanWrite Then
        If Not text.EndsWith(vbCr & vbLf) Then
            text += Environment.NewLine
        End If
        Dim sendBytes As Byte() = Encoding.UTF8.GetBytes(text)
        netStream.Write(sendBytes, 0, sendBytes.Length)
    Else
        err = "cannot write to the stream"
    End If
End Sub
Public Function initiate() As TcpClient
    Dim TcpClient As New TcpClient()
    Dim bytCommand As Byte() = New Byte(1023) {}
    TcpClient.Connect(_GLOIP, _port)
    Return TcpClient
End Function
4

0 回答 0