Vb.net TCP客户端发送的数据包未到达目的地
我正在尝试使用tcpclient向具有提供端口的远程服务器发送消息。在我的代码中,我看到连接成功并发送了消息,但另一端的开发人员通知我没有收到消息。是否有任何方法来调试这个Vb.net TCP客户端发送的数据包未到达目的地,vb.net,tcpclient,networkstream,Vb.net,Tcpclient,Networkstream,我正在尝试使用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 = ini
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
您是否检查了端口是否在途中的某个位置被阻塞()。此外,您还可以使用WireShark()之类的工具来检查您机器上的流量。谢谢,我们将看一看