遇到一个问题:
***************************客户端*********************
Private Sub Form_Load()
' 指定服务器主机名
SockClient.RemoteHost = "127.0.0.1"
' 指定服务器端口名
SockClient.RemotePort = 2000
' 连接到服务器
SockClient.Connect
WebBrowser1.Navigate http://my.yahoo.com '这里,如果写上这句则出现错误;注释掉则正常运行
End Sub
Private Sub SockClient_DataArrival(ByVal bytesTotal As Long)
Dim DataStr As String
SockClient.GetData DataStr
Debug.Print "接受的数据:" & DataStr '正常应显示True
End Sub
Private Sub Form_Unload(Cancel As Integer)
sockserver.Close
End Sub
***************************服务端********************************
Private Sub Form_Load()
sockserver.LocalPort = 2000 '服务器端口号,最好大于1000
sockserver.Listen '开始侦听
End Sub
' 建立新连接
Private Sub SockServer_ConnectionRequest(ByVal requestID As Long)
If sockserver.State <> sckClosed Then sockserver.Close
sockserver.Accept requestID '表示客户请求连接的ID号
SendMsg = True
sockserver.SendData SendMsg
End Sub
Private Sub Form_Unload(Cancel As Integer)
sockserver.Close
End Sub