| Check if port is in Use |
|
|
|
| Tutorials | |||
| Written by Administrator | |||
|
Use to function below to check if a port is in use. For instance to test port 80 IsPortinUse(80) will return a true/false status. [code] Private Function IsPortinUse(ByVal PortNumber As Integer) As Boolean
'*************************************
'**** Code from VisibleVisual.co' ****
'*************************************
Dim oSocket As Object
Dim bAns As Boolean
On Error Resume Next
Set oSocket = CreateObject("MSWinsock.Winsock.1")
If Err.Number > 0 Then
Err.Raise 30000, , "Could not create winsock object"
Exit Function
End If
Err.Clear
oSocket.LocalPort = PortNumber
oSocket.Listen
bAns = Err.Number = 10048 'port is busy
oSocket.Close
Set oSocket = Nothing
IsPortinUse = bAns
End Function
[/code]
|


