VB6 Winsock Error Invalid Argument 10014
Private Sub Form_Load()
Winsock1.RemotePort = 22222
Winsock1.Protocol = sckUDPProtocol
End Sub
Private Sub Command1_Click()
Command1.Enabled = False
Dim sendBuff As String
sendBuff = "XXXXX"
Label1:
On Error GoTo Label2
Winsock1.RemoteHost = "andon-eds-1"
Winsock1.SendData sendBuff
Label2:
Winsock1.Close
Winsock1.Protocol = sckUDPProtocol
Winsock1.RemotePort = 22222
Winsock1.LocalPort = 0
Label3:
On Error GoTo EndOfSub
Winsock1.RemoteHost = "andon-eds-1"
Winsock1.SendData sendBuff
EndOfSub:
Command1.Enabled = True
End Sub
Private Sub Command2_Click()
Command2.Enabled = False
On Error GoTo EndOfSub
Winsock1.RemoteHost = "andon-eds-1"
Winsock1.SendData "XXXXX"
EndOfSub:
Command2.Enabled = True
End Sub
Private Sub Command3_Click()
On Error Resume Next
Command3.Enabled = False
Dim sendBuff As String
sendBuff = "XXXXX"
PrintWinsockProperty
Winsock1.RemoteHost = "andon-eds-1"
Winsock1.SendData sendBuff
PrintWinsockProperty
Winsock1.Close
Winsock1.Protocol = sckUDPProtocol
Winsock1.RemotePort = 22222
Winsock1.LocalPort = 0
PrintWinsockProperty
Winsock1.RemoteHost = "andon-eds-1"
Winsock1.SendData sendBuff
PrintWinsockProperty
Command3.Enabled = True
End Sub
'the host name "andon-eds-1" is not online and i want my application can continues
- when i click Command1 i found an error Invalid Argument : 10014 at >>Winsock1.SendData sendBuff << below Label3 my application cannot continues
- when i click Command2 2 times it can continues without application close
when i click Command3 it c开发者_运维问答an continues without application close
my question are what's the difference between 1.) and 2.) ? and what's difference between On Error Resume Next and On Error GoTo for my problem ? (** i'm sorry about my english skills) thanksPrivate Sub Command6_Click() Dim i As Integer Command6.Enabled = False On Error GoTo BeginLoop Winsock1.RemoteHost = "Andon-eds-1" Winsock1.SendData "XXXXX" BeginLoop: Resume Next For i = 0 To 2 Winsock1.RemoteHost = "Andon-eds-" & i Winsock1.SendData "XXXXX" Debug.Print Err.Number '0 '0 '0 Next On Error GoTo TestLabel i = 100 / 0 Command6.Enabled = True Exit Sub TestLabel: End Sub
I'm not sure what you are trying to do with the code so I can't answer your entire question but I can answer this part of your question:
What's the difference between On Error Resume Next and On Error GoTo.
Resume next will cause execution to go on to the next line of code if an error happens. For On Error GoTo, that will take your code to the label specified after the GoTo in the section of code that follows the On Error GoTo.
Error 10014 (WSAEFAULT) is Bad Address
The system detected an invalid pointer address in attempting to use a pointer argument of a call. This error occurs if an application passes an invalid pointer value, or if the length of the buffer is too small. For instance, if the length of an argument, which is a sockaddr structure, is smaller than the sizeof(sockaddr).
Check that the machine "andon-eds-1"
can be pinged ok
精彩评论