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

Re: Determining port by name

name
Tue Dec 30 01:29:39 CST 2003


Courtesy scripting wsh group posted hta application result :

'=====================================
'
' Description: Microsoft Winsock Control 6.0 (SP5)
'
' Name: MSWinsockLib
' Version: 1.0 [of Type Library]
' GUID: {248DD890-BB45-11CF-9ABC-0080C7E7B78D}
'
' File: c:\windows\system\mswinsck.ocx
' Version: 6.0.89.88 [of file]
'
' Extracted on: 12/29/03 3:32:12 PM
'
'=====================================
' ErrorConstants
'=====================================
Const sckAddressInUse = 10048
Const sckAddressNotAvailable = 10049
Const sckAlreadyComplete = 10037
Const sckAlreadyConnected = 10056
Const sckBadState = 40006
Const sckConnectAborted = 10053
Const sckConnectionRefused = 10061
Const sckConnectionReset = 10054
Const sckGetNotSupported = 394
Const sckHostNotFound = 11001
Const sckHostNotFoundTryAgain = 11002
Const sckInProgress = 10036
Const sckInvalidArg = 40014
Const sckInvalidArgument = 10014
Const sckInvalidOp = 40020
Const sckInvalidPropertyValue = 380
Const sckMsgTooBig = 10040
Const sckNetReset = 10052
Const sckNetworkSubsystemFailed = 10050
Const sckNetworkUnreachable = 10051
Const sckNoBufferSpace = 10055
Const sckNoData = 11004
Const sckNonRecoverableError = 11003
Const sckNotConnected = 10057
Const sckNotInitialized = 10093
Const sckNotSocket = 10038
Const sckOpCanceled = 10004
Const sckOutOfMemory = 7
Const sckOutOfRange = 40021
Const sckPortNotSupported = 10043
Const sckSetNotSupported = 383
Const sckSocketShutdown = 10058
Const sckSuccess = 40017
Const sckTimedout = 10060
Const sckUnsupported = 40018
Const sckWouldBlock = 10035
Const sckWrongProtocol = 40026
'=====================================
' ProtocolConstants
'=====================================
Const sckTCPProtocol = 0
Const sckUDPProtocol = 1
'=====================================
' StateConstants
'=====================================
Const sckClosed = 0
Const sckClosing = 8
Const sckConnected = 7
Const sckConnecting = 6
Const sckConnectionPending = 3
Const sckError = 9
Const sckHostResolved = 5
Const sckListening = 2
Const sckOpen = 1
Const sckResolvingHost = 4














"LegroocH" <gruchal@o2.pl> wrote in message
news:ePofUPezDHA.4064@tk2msftngp13.phx.gbl...
> 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?


Re: Determining port by LegroocH

LegroocH
Tue Dec 30 03:23:32 CST 2003

Thanks for help :)



Uzytkownik "name" <nospam@user.com> napisal w wiadomosci
news:eM1CkhqzDHA.2056@TK2MSFTNGP10.phx.gbl...
>
> Courtesy scripting wsh group posted hta application result :
>
> '=====================================
> '
> ' Description: Microsoft Winsock Control 6.0 (SP5)
> '
> ' Name: MSWinsockLib
> ' Version: 1.0 [of Type Library]
> ' GUID: {248DD890-BB45-11CF-9ABC-0080C7E7B78D}
> '
> ' File: c:\windows\system\mswinsck.ocx
> ' Version: 6.0.89.88 [of file]
> '
> ' Extracted on: 12/29/03 3:32:12 PM
> '
> '=====================================
> ' ErrorConstants
> '=====================================
> Const sckAddressInUse = 10048
> Const sckAddressNotAvailable = 10049
> Const sckAlreadyComplete = 10037
> Const sckAlreadyConnected = 10056
> Const sckBadState = 40006
> Const sckConnectAborted = 10053
> Const sckConnectionRefused = 10061
> Const sckConnectionReset = 10054
> Const sckGetNotSupported = 394
> Const sckHostNotFound = 11001
> Const sckHostNotFoundTryAgain = 11002
> Const sckInProgress = 10036
> Const sckInvalidArg = 40014
> Const sckInvalidArgument = 10014
> Const sckInvalidOp = 40020
> Const sckInvalidPropertyValue = 380
> Const sckMsgTooBig = 10040
> Const sckNetReset = 10052
> Const sckNetworkSubsystemFailed = 10050
> Const sckNetworkUnreachable = 10051
> Const sckNoBufferSpace = 10055
> Const sckNoData = 11004
> Const sckNonRecoverableError = 11003
> Const sckNotConnected = 10057
> Const sckNotInitialized = 10093
> Const sckNotSocket = 10038
> Const sckOpCanceled = 10004
> Const sckOutOfMemory = 7
> Const sckOutOfRange = 40021
> Const sckPortNotSupported = 10043
> Const sckSetNotSupported = 383
> Const sckSocketShutdown = 10058
> Const sckSuccess = 40017
> Const sckTimedout = 10060
> Const sckUnsupported = 40018
> Const sckWouldBlock = 10035
> Const sckWrongProtocol = 40026
> '=====================================
> ' ProtocolConstants
> '=====================================
> Const sckTCPProtocol = 0
> Const sckUDPProtocol = 1
> '=====================================
> ' StateConstants
> '=====================================
> Const sckClosed = 0
> Const sckClosing = 8
> Const sckConnected = 7
> Const sckConnecting = 6
> Const sckConnectionPending = 3
> Const sckError = 9
> Const sckHostResolved = 5
> Const sckListening = 2
> Const sckOpen = 1
> Const sckResolvingHost = 4
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> "LegroocH" <gruchal@o2.pl> wrote in message
> news:ePofUPezDHA.4064@tk2msftngp13.phx.gbl...
> > 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?
>