下面是我的原代码,我是在一太电脑上放了两个WINSOCK,但是一运行,点击发送就出来40006:wrong protocal or connection state for the request transaction
or request
这是怎么回事呢?
Private Sub cmd_connect_Click()
Sockclient.RemoteHost = txt_ip.Text
Sockclient.Connect
End SubPrivate Sub cmd_end_Click()
Sockclient.SendData "quit"
End SubPrivate Sub cmd_quit_Click()
End
End SubPrivate Sub cmd_send_Click()
Dim MySendData As String
MySendData = Txt_send.Text
Sockclient.SendData MySendData
Txt_send.Text = ""
End SubPrivate Sub Form_Load()
Sockserver.Listen
End SubPrivate Sub Sockclient_Close()
cmd_connect.Enabled = True
Txt_send.Text = ""
Txt_get.Text = ""
End SubPrivate Sub Sockclient_Connect()
MsgBox "连接成功", vbInformation, "ok" & vbCr
cmd_connect.Enabled = False
End SubPrivate Sub Sockclient_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)
Sockclient.Close
End SubPrivate Sub Sockserver_Close()
cmd_connect.Enabled = True
End SubPrivate Sub Sockserver_ConnectionRequest(ByVal requestID As Long)
If Sockserver.State <> sckClosed Then Sockserver.Close
Sockserver.Accept requestID
End SubPrivate Sub Sockserver_DataArrival(ByVal bytesTotal As Long)
Dim MyGetData As String
Sockserver.GetData MyGetData
If MyGetData = "quit" Then
Sockserver.Close
Sockserver.Listen
End If
Txt_get.Text = Txt_get.Text & Chr(13) & Chr(10) & MyGetData
End SubPrivate Sub Timer1_Timer()
'Select Case Sockclient.State
' Case 0: StatusBar1.Panels(2) = "客户端关闭"
' Case 1: StatusBar1.Panels(2) = "客户端打开"
' Case 7: StatusBar1.Panels(2) = "客户端已经连接"
'End Select
'Select Case Sockserver.State
' Case 0: StatusBar1.Panels(1) = "服务器关闭"
' Case 2: StatusBar1.Panels(1) = "服务器帧听"
' Case 7: StatusBar1.Panels(1) = "服务器已经连接"
'End Select
End SubPrivate Sub Txt_send_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
cmd_send_Click
End If
End Sub
or request
这是怎么回事呢?
Private Sub cmd_connect_Click()
Sockclient.RemoteHost = txt_ip.Text
Sockclient.Connect
End SubPrivate Sub cmd_end_Click()
Sockclient.SendData "quit"
End SubPrivate Sub cmd_quit_Click()
End
End SubPrivate Sub cmd_send_Click()
Dim MySendData As String
MySendData = Txt_send.Text
Sockclient.SendData MySendData
Txt_send.Text = ""
End SubPrivate Sub Form_Load()
Sockserver.Listen
End SubPrivate Sub Sockclient_Close()
cmd_connect.Enabled = True
Txt_send.Text = ""
Txt_get.Text = ""
End SubPrivate Sub Sockclient_Connect()
MsgBox "连接成功", vbInformation, "ok" & vbCr
cmd_connect.Enabled = False
End SubPrivate Sub Sockclient_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)
Sockclient.Close
End SubPrivate Sub Sockserver_Close()
cmd_connect.Enabled = True
End SubPrivate Sub Sockserver_ConnectionRequest(ByVal requestID As Long)
If Sockserver.State <> sckClosed Then Sockserver.Close
Sockserver.Accept requestID
End SubPrivate Sub Sockserver_DataArrival(ByVal bytesTotal As Long)
Dim MyGetData As String
Sockserver.GetData MyGetData
If MyGetData = "quit" Then
Sockserver.Close
Sockserver.Listen
End If
Txt_get.Text = Txt_get.Text & Chr(13) & Chr(10) & MyGetData
End SubPrivate Sub Timer1_Timer()
'Select Case Sockclient.State
' Case 0: StatusBar1.Panels(2) = "客户端关闭"
' Case 1: StatusBar1.Panels(2) = "客户端打开"
' Case 7: StatusBar1.Panels(2) = "客户端已经连接"
'End Select
'Select Case Sockserver.State
' Case 0: StatusBar1.Panels(1) = "服务器关闭"
' Case 2: StatusBar1.Panels(1) = "服务器帧听"
' Case 7: StatusBar1.Panels(1) = "服务器已经连接"
'End Select
End SubPrivate Sub Txt_send_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
cmd_send_Click
End If
End Sub
sckClosed 0 Default. Closed
sckOpen 1 Open
sckListening 2 Listening
sckConnectionPending 3 Connection pending
sckResolvingHost 4 Resolving host
sckHostResolved 5 Host resolved
sckConnecting 6 Connecting
sckConnected 7 Connected
sckClosing 8 Peer is closing the connection
sckError 9 Error