'加入下面的代码就行了
Private Sub Winsock1_Connect() '连接成功后,会发生Connect事件
MsgBox "连接成功"
End Sub
Private Sub Winsock1_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean) '连接出错就重新连接
Winsock1.Close
Winsock1.Connect
End Sub
6个问题,解决一个加5分问题1:用WinSock控件不能绑定(bind),不然出现winsock传文件的代码百度一下大把大把的有。 3.winsock有一个属性 state.
添加一个Timer,把connect这个活,放到Timer_timer里。如果 winsock1.state=7 (7表示连接成功),则Timer.enabled=false