I had start recently to study winsck VB programming and it came to me about doing a simple port scanner. I´ve tried to do a simple class D scanner but I just can´t figure why it doens´t find any open port! Every port he finds its closed! I´ve tried with a port scanner I have and it finds an open port but when I try with this the port is closed!!
I just can´t figure out why this doesn´t work!
...Another thing... How can I stop the scanner?
Here's the code:

For forth = classD1.Text To classD2.Text
tcpsock.Protocol = sckTCPProtocol
tcpsock.RemoteHost = classA1.Text & "." & classB1.Text & "." & classC1.Text & "." & forth
tcpsock.RemotePort = 21
If tcpsock.State <> sckConnected Then
log.Text = tcpsock.RemoteHost & "  Closed !!"
log.Text = tcpsock.RemoteHost & "  Open !!"
End If
Call Pause(x)  'Pause for x seconds (The program is going to get the x from a text box)
Next forth
Who is Participating?
VBGuruConnect With a Mentor Commented:
use it like this
Private Sub Form_Click()

End Sub

Private Sub Winsock1_Connect()
If Winsock1.State <> sckConnected Then
MsgBox "  Closed !!"
MsgBox "  Open !!"
End If
End Sub

alexbeatyAuthor Commented:
It works fine!!

But why don´t mine works?

Thx anyway
Because that time when you test for the state of the winsock it is not connected to the server.
Connect event Occurs after a connection is established to the server.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.