Determine if Windows is using TCP / IP port?

In a cross platform environment, I am using a built-in function that should indicate if a tcp port is available. However, the function runs on Vista and always returns "available".

Is there an easy way, like a dll function, I can use to correctly identify this information without requiring .Net?

+1


a source to share


3 answers


You can try to bind and listen on the port using normal Winsock functions. If something else is already listening on the same port, you will receive an error message ( WSAEADDRINUSE

from bind()

).



+2


a source


To avoid adding any added dependencies or Windows specific code, you can simply try to use the port and catch any issues (like interception by firewall software).



0


a source


Just use Win32 Nw apis to list TCP ports.

0


a source







All Articles