vb用Winsock控件出现问题,请大来帮忙看一下,实在找不出错误在哪啊? 实时错误40020(当前状态的操作无效 5
'远程计算机请求连接PrivateSubWinsock1_ConnectionRequest(IndexAsInteger,ByValRequestIDAsLong)'W...
'远程计算机请求连接
Private Sub Winsock1_ConnectionRequest(Index As Integer, ByVal RequestID As Long)
'Winsock1(Index).Close '-----------------------------------
intWinSockCounts = intWinSockCounts + 1
intClientNums = intClientNums + 1
If Winsock1.UBound < 10 Then
Load Winsock1(intWinSockCounts)
End If
Winsock1(intWinSockCounts).LocalPort = 0 '设置本地端口‘(调试时就是这里附近出错误)
Winsock1(intWinSockCounts).Accept RequestID '接收新连接
StatusBar1.Panels(2).Text = "接受客户机请求,连接建立成功"
Shape1.FillColor = vbGreen
Text6.Text = intWinSockCounts
If Val(Text6.Text) >= 10 Then ''100
intWinSockCounts = 1
End If
End Sub
急啊。。。求高人指导。。谢谢 展开
Private Sub Winsock1_ConnectionRequest(Index As Integer, ByVal RequestID As Long)
'Winsock1(Index).Close '-----------------------------------
intWinSockCounts = intWinSockCounts + 1
intClientNums = intClientNums + 1
If Winsock1.UBound < 10 Then
Load Winsock1(intWinSockCounts)
End If
Winsock1(intWinSockCounts).LocalPort = 0 '设置本地端口‘(调试时就是这里附近出错误)
Winsock1(intWinSockCounts).Accept RequestID '接收新连接
StatusBar1.Panels(2).Text = "接受客户机请求,连接建立成功"
Shape1.FillColor = vbGreen
Text6.Text = intWinSockCounts
If Val(Text6.Text) >= 10 Then ''100
intWinSockCounts = 1
End If
End Sub
急啊。。。求高人指导。。谢谢 展开
展开全部
intWinSockCounts = intWinSockCounts + 1
intClientNums = intClientNums + 1
If Winsock1.UBound < 10 Then
Load Winsock1(intWinSockCounts)
End If
改为:
If Winsock1.UBound < 10 Then
intWinSockCounts = intWinSockCounts + 1
intClientNums = intClientNums + 1
Load Winsock1(intWinSockCounts)
End If
试试呢。
intClientNums = intClientNums + 1
If Winsock1.UBound < 10 Then
Load Winsock1(intWinSockCounts)
End If
改为:
If Winsock1.UBound < 10 Then
intWinSockCounts = intWinSockCounts + 1
intClientNums = intClientNums + 1
Load Winsock1(intWinSockCounts)
End If
试试呢。
更多追问追答
追问
因为我是用两个客户端的啊,只要他们间两个一起连接,到时再断开,再连接就又会出这个“实时错误40020(当前状态的操作无效”这个问题呀??
追答
你是用的winsock控件数组,并且还存在重复使用问题,所以在关闭连接时要释放资源,再次连接时,要先检测哪一个是可用的才行。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询