按照你的TCP编写的VB,连接之后服务器向客户端发送数据,接收不到。 10
服务器程序:PrivateSubCommand1_Click()tcpServer.LocalPort=Text1.TexttcpServer.ListenEndSubP...
服务器程序:
Private Sub Command1_Click()
tcpServer.LocalPort = Text1.Text
tcpServer.Listen
End Sub
Private Sub Form_Load()
frmClient.Show
End Sub
Private Sub send_Change()
tcpServer.SendData send.Text
End Sub
Private Sub tcpServer_ConnectionRequest(ByVal requestID As Long)
If tcpServer.State <> sckClosed Then tcpServer.Close
tcpServer.Accept requestID
End Sub
Private Sub tcpServer_DataArrival(ByVal bytesTotal As Long)
Dim strData As String
tcpServer.GetData strData, vbString
Output.Text = strData
End Sub
客户端程序
Private Sub cmdConnect_Click()
tcpClient.RemoteHost = Trim(Text1.Text)
tcpClient.RemotePort = Text2.Text
tcpClient.Connect
End Sub
Private Sub Form_Load()
'tcpClient.RemoteHost = "49.123.76.142"
End Sub
Private Sub tcpCllient_DataArrival(ByVal bytesTotal As Long)
Dim strData As String
tcpClient.GetData strData, vbString
txtOutput.Text = strData
End Sub
Private Sub txtSend_Change()
tcpClient.SendData txtSend.Text
End Sub 展开
Private Sub Command1_Click()
tcpServer.LocalPort = Text1.Text
tcpServer.Listen
End Sub
Private Sub Form_Load()
frmClient.Show
End Sub
Private Sub send_Change()
tcpServer.SendData send.Text
End Sub
Private Sub tcpServer_ConnectionRequest(ByVal requestID As Long)
If tcpServer.State <> sckClosed Then tcpServer.Close
tcpServer.Accept requestID
End Sub
Private Sub tcpServer_DataArrival(ByVal bytesTotal As Long)
Dim strData As String
tcpServer.GetData strData, vbString
Output.Text = strData
End Sub
客户端程序
Private Sub cmdConnect_Click()
tcpClient.RemoteHost = Trim(Text1.Text)
tcpClient.RemotePort = Text2.Text
tcpClient.Connect
End Sub
Private Sub Form_Load()
'tcpClient.RemoteHost = "49.123.76.142"
End Sub
Private Sub tcpCllient_DataArrival(ByVal bytesTotal As Long)
Dim strData As String
tcpClient.GetData strData, vbString
txtOutput.Text = strData
End Sub
Private Sub txtSend_Change()
tcpClient.SendData txtSend.Text
End Sub 展开
1个回答
展开全部
在客户端程序接收过程名写错了tcpCllient中多了一个l, 应该为tcpClient
Private Sub tcpCllient_DataArrival(ByVal bytesTotal As Long)
Dim strData As String
tcpClient.GetData strData, vbString
txtOutput.Text = strData
End Sub
改成如下:
Private Sub tcpClient_DataArrival(ByVal bytesTotal As Long)
Dim strData As String
tcpClient.GetData strData, vbString
txtOutput.Text = strData
End Sub
Private Sub tcpCllient_DataArrival(ByVal bytesTotal As Long)
Dim strData As String
tcpClient.GetData strData, vbString
txtOutput.Text = strData
End Sub
改成如下:
Private Sub tcpClient_DataArrival(ByVal bytesTotal As Long)
Dim strData As String
tcpClient.GetData strData, vbString
txtOutput.Text = strData
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询