Hi,
hab hier einen Port-Scanner-Code, is zwar net von mir, aber verdammt schnell.
Wsk heisst das Winsock-Element
Die anderen Elemente wirst'e schon finden
-------------Snip----------
Public Max_Con
Public Max_Port
Public Last_Checked
Public url As String
Private Is_ready(33999) As Ready
Private Type Ready
Value As Integer
End Type
Private Sub Command1_Click()
blah = InputBox("How Many Sockets? (500 is good)", HowMany, 500)
Max_Con = blah
For x = 1 To blah
Load Wsk(x)
Next x
End Sub
Private Sub Command2_Click()
url = InputBox("URL to SCAN", , "localhost")
Me.Caption = url
Max_Port = InputBox("Maximum port to scan")
Call Check
End Sub
Private Sub Timer1_Timer()
Label3.Caption = Val(Label3.Caption) + 1 & " Second/s"
End Sub
Private Sub Wsk_Connect(Index As Integer)
Label1.Caption = "Last Checked In: " & Wsk(Index).RemotePort
List1.AddItem Index, 0
Wsk(Index).Close: Is_ready(Index).Value = 0 'set socket ready
End Sub
Private Sub Wsk_Error(Index As Integer, 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)
Label1.Caption = "Last Checked In: " & Wsk(Index).RemotePort
Wsk(Index).Close: Is_ready(Index).Value = 0 'set socket ready
End Sub
Sub Check()
Strt:
Timer1.Enabled = True
DoEvents
For x = 1 To Max_Con
DoEvents
'Wsk(x).Close This is Bad!!
If Is_ready(x).Value <> 0 Then GoTo 20: ' Socket Isnt done checking skip
Wsk(x).Connect url, Last_Checked + 1
Is_ready(x).Value = 1 'Set socket not ready
Last_Checked = Last_Checked + 1
Label2.Caption = "Next To Be Scanned: " & Last_Checked
20:
Next x
If Val(Last_Checked) >= Val(Max_Port) Then
Timer1.Enabled = False
For y = 1 To Max_Con
'Clean Up
Is_ready(y).Value = 0
Unload Wsk(y)
Next y
MsgBox ("Stoped")
Exit Sub
Else:
GoTo Strt:
End If
End Sub
-------------Snip----------
Hth
KarlBerg