ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to write a VBA code to check whether TCP port (e.g.3306) isblocked or not? (https://www.excelbanter.com/excel-programming/450304-how-write-vba-code-check-whether-tcp-port-e-g-3306-isblocked-not.html)

SOS[_41_]

How to write a VBA code to check whether TCP port (e.g.3306) isblocked or not?
 
Hi,

Can anyone please help me to find out a way to check whether a local TCP Outbound/Inbound blocked or not? Many thanks in advance!

Best regards
Ratheesh

GS[_2_]

How to write a VBA code to check whether TCP port (e.g.3306) is blocked or not?
 
Hi,

Can anyone please help me to find out a way to check whether a local
TCP Outbound/Inbound blocked or not? Many thanks in advance!

Best regards
Ratheesh


Perhaps...

http://www.example-code.com/vb/tcp-socket-connect.asp

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion



Ratheesh Panakkil

How to write a VBA code to check whether TCP port (e.g.3306) isblocked or not?
 
Hi Garry,

Thanks for your help! goes a very long way.

Finally I found a way to get the TCP port status, I hope this would help someone.

Set objFirewall = CreateObject("HNetCfg.FwMgr")
Set objPolicy = objFirewall.LocalPolicy.CurrentProfile
Set objPort = CreateObject("HNetCfg.FwOpenPort")

objPort.Port = YourPortNumber

Then check whether it is enabled or not - objPort.Enabled

Hope this will help

Best regards
Ratheesh

GS[_2_]

How to write a VBA code to check whether TCP port (e.g.3306) is blocked or not?
 
Or simply...


Function IsTcpEnabled(Optional PortNum&) As Boolean
If PortNum = 0 Then PortNum = 119 '//edit to actual
With CreateObject("HNetCfg.FwOpenPort")
.Port = PortNum: IsTcpEnabled = .Enabled
End With
End Function

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion



GS[_2_]

How to write a VBA code to check whether TCP port (e.g.3306) is blocked or not?
 
Note that this only 'assigns' a port#, and returns whether or not that
port# is enabled. It does not tell you if an existing port# on
'localhost' is enabled!

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion



SOS[_42_]

How to write a VBA code to check whether TCP port (e.g.3306) isblocked or not?
 
Ok.
Actually I need to check the Incoming Port 3306(MySQL) to get a key. If that disabled, I need to open the port for a limited time and get the information.

Many thanks!
Ratheesh


All times are GMT +1. The time now is 06:02 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com