VB实时错误40006所需事物或请求的错误协议或连接状态,附代码
服务器PrivateSubForm_Load()tcpServer.LocalPort=2008tcpServer.ListenEndSubPrivateSubtcpSe...
服务器Private Sub Form_Load()
tcpServer.LocalPort = 2008
tcpServer.Listen
End SubPrivate Sub tcpServer_ConnectionRequest(ByVal requestID As Long)
If tcpServer.State <> sckClosed Then
tcpServer.Close
tcpServer.Accept requestID
End IfEnd Sub
Private Sub Command1_Click()
tcpServer.SendData txtSendData.Text
End Sub
Private Sub tcpServer_DataArrival(ByVal bytesTotal As Long)
Dim strData As StringtcpServer.GetData Tmp, vbString
txtOutput.Text = Tmp
End Sub
客户端
Private Sub cmdConnect_Click()
tcpClient.Connect Text1.Text, 2008
txtOutput.Text = "恭喜您,已成功连接到服务器!" '提示连接成功
End SubPrivate Sub Command1_Click()
tcpClient.SendData txtSendData.Text
End Sub
Private Sub tcpClient_DataArrival(ByVal bytesTotal As Long)
Dim strData As String tcpClient.GetData Tmp, vbString
txtOutput.Text = Tmp
End Sub
Private Sub Command2_Click() txtOutput.Text = "您已断开连接" + Chr$(13) + Chr$(10) + txtOutput.Text tcpClient.Close
End Sub
求大神帮我看看哪儿出错了,本人没学过VB因做课设临时看了几天,有什么地方犯了什么低级错误不要鄙视我啊。。。。。。 展开
tcpServer.LocalPort = 2008
tcpServer.Listen
End SubPrivate Sub tcpServer_ConnectionRequest(ByVal requestID As Long)
If tcpServer.State <> sckClosed Then
tcpServer.Close
tcpServer.Accept requestID
End IfEnd Sub
Private Sub Command1_Click()
tcpServer.SendData txtSendData.Text
End Sub
Private Sub tcpServer_DataArrival(ByVal bytesTotal As Long)
Dim strData As StringtcpServer.GetData Tmp, vbString
txtOutput.Text = Tmp
End Sub
客户端
Private Sub cmdConnect_Click()
tcpClient.Connect Text1.Text, 2008
txtOutput.Text = "恭喜您,已成功连接到服务器!" '提示连接成功
End SubPrivate Sub Command1_Click()
tcpClient.SendData txtSendData.Text
End Sub
Private Sub tcpClient_DataArrival(ByVal bytesTotal As Long)
Dim strData As String tcpClient.GetData Tmp, vbString
txtOutput.Text = Tmp
End Sub
Private Sub Command2_Click() txtOutput.Text = "您已断开连接" + Chr$(13) + Chr$(10) + txtOutput.Text tcpClient.Close
End Sub
求大神帮我看看哪儿出错了,本人没学过VB因做课设临时看了几天,有什么地方犯了什么低级错误不要鄙视我啊。。。。。。 展开
4个回答
展开全部
我遇到的情况是winsock设置在TCP模式,实际上我程序用的是UDP
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
出错时停在哪行? 截个图上来。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
双方都用VB写。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询