winsock 控件 连接2台电脑的问题
我用winsock尝试网络连接 按照书里的代码更改为自己的IP地址
这是服务器端的代码
Private Sub Form_Load()
WinServer.LocalPort = 1001
WinServer.Listen
End Sub
Private Sub WinServer_ConnectionRequest(ByVal requestID As Long)
If WinServer.State <> sckClosed Then
WinServer.Close
End If
WinServer.Accept requestID
End Sub
Private Sub WinServer_DataArrival(ByVal bytesTotal As Long)
Dim strData As String
WinServer.GetData strData
txtTalk.Text = txtTalk.Text + Chr(13) + Chr(10) + " 客户端说 - " + strData
End Sub
Private Sub Command1_Click()
WinServer.SendData txtInput.Text
txtTalk.Text = txtTalk.Text + Chr(13) + Chr(10) + " 服务器端说 - " + txtInput.Text
End Sub
下面是客户端的代码
Private Sub cmdConn_Click()
If WinClient.State = sckConnected Then
Exit Sub
End If
WinClient.RemoteHost = "125.127.75.187"
WinClient.RemotePort = 1001
WinClient.Connect
End Sub
Private Sub cmdSend_Click()
WinClient.SendData txtInput.Text
txtTalk.Text = txtTalk.Text + Chr(13) + Chr(10) + " 客户端说 - " + txtInput.Text
End Sub
Private Sub WinClient_DataArrival(ByVal bytesTotal As Long)
Dim strData As String
WinClient.GetData strData
txtTalk.Text = txtTalk.Text + Chr(13) + Chr(10) + " 服务器端说 - " + strData
End Sub
当客户端与服务端用在1台机子上的时候 连接没问题
当把客户端放在另外1台机子上的时候就提示 错误 40006
这是为什么。。。。
我的是拨号上网 是不是跟这个有关
补充:VB , 网络编程