Re: Newbie with VB6 winsock
try checking for the connect in the winsock connect sub, also check the state
Private Sub Winsock1_Connect()
If Winsock1.State = sckConnected Then
'connected add code
Else
'add other code error code, etc
End If
End Sub
Re: Newbie with VB6 winsock
Quote:
Originally Posted by Calimorphos
I'm sure that my script doesn't work but how learn without mistake ^^
Thx for your help
Welcome to the forums. :)
What specific problems are you having? That was not stated in your post.
Re: Newbie with VB6 winsock
That's right, my question was not well set. Exactly i have a problem with the line 7:
compilation error
unknown type (*unknown shouldn't be the righr word but I translate FR/EN sorry ^^)
Thx for your answers
Re: Newbie with VB6 winsock
hi,
You need to check if connected by checking the winsock state.
ok I left some code below . it will need some work but gives you a basic idea. anyway hope it may help you a little get started.
VB Code:
Private Sub Command1_Click()
Winsock1.RemoteHost = "dream"
Winsock1.Protocol = sckTCPProtocol
Winsock1.RemotePort = 21
Winsock1.Connect
End Sub
Private Sub Winsock1_Connect()
' check for a connection. also see StateConstants for more consts
If Winsock1.State = sckConnected Then
MsgBox "Connected"
Else
MsgBox "Not connected"
End If
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim sdata As String, e_pos As Integer, sCmd As String
DoEvents
Winsock1.GetData sdata, , bytesTotal
e_pos = InStr(1, sdata, Chr(32), vbBinaryCompare)
If e_pos <> 0 Then sCmd = Trim(Left(sdata, e_pos)) 'Get ftp commands
Select Case sCmd
Case 220 'Welcome message
MsgBox Right(sdata, Len(sdata) - Len(sCmd))
'send username
Winsock1.SendData "USER ben" & vbCrLf
Case 331
'send password
Winsock1.SendData "PASS ben" & vbCrLf
Case 530
'incorrect login or password
MsgBox Right(sdata, Len(sdata) - Len(sCmd))
End Select
End Sub