I need to know, that port 25 on my server is opened. I have a code, but i
don't want to use winsock. Anyone have any idea?
Here is my code:
Dim Sock
set Sock = createobject("MSWINSOCK.Winsock")
Main
Sub Main()
' For i = 19 To 25 Step 1
CheckPort "srv1srv", 25
' Next
End Sub
Function CheckPort(RemoteHost, Port)
'On Error Resume Next
Sock.RemotePort = Port
Sock.RemoteHost = RemoteHost
Sock.Connect
Dim WshShell
set WshShell = WScript.CreateObject("WScript.Shell")
Dim Counter
Counter = 0
While Sock.State <> 7 And Sock.State <> 8 And Sock.State <> 9 And Counter <
5
'Give it 25 seconds to connect before continuing:
Counter = Counter + 1
WScript.Sleep 5000
Wend
set WshShell = nothing
If Sock.State = 7 Then
MsgBox "Port " & Port & " is accepting connections!"
ElseIf Counter = 5 Then
MsgBox "Request timed out. Check the server your connecting to."
Else
MsgBox RemoteHost & ":" & Port & " is rejecting connection."
End If
If Sock.State <> 0 Then Sock.Close
End Function