按照你的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
展开
 我来答
百度网友cc69e68
2014-09-16 · TA获得超过216个赞
知道小有建树答主
回答量:393
采纳率:84%
帮助的人:182万
展开全部
在客户端程序接收过程名写错了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
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式