LISTENING TCP Ports - how to determine? 
Author Message
 LISTENING TCP Ports - how to determine?

Is there any way to programmatically determine which TCP ports are
currently actively in a LISTENING state?  I can do this with netstat
-an -p tcp of course but I wanted to put this into a DLL function.
I've tried playing around with the MFC CSocket class.  But I'm finding
that calls to Create() and Listen() on the port will succeed on ports
that are in the LISTENING state -- just not on ports with ESTABLISHED
sessions.  I want to find a way to make sure that the port a user is
allowed to select is not in a LISTENING state at all to hopefully
preclude any conflicts later.  Thanks in advance!
-Bill


Tue, 13 Sep 2005 20:46:06 GMT  
 LISTENING TCP Ports - how to determine?
I have an app that creates a listening socket and the Create() will fail if
the port is already listening. GetLastError() returns WSAEADDRINUSE.

Mike


Quote:
> Is there any way to programmatically determine which TCP ports are
> currently actively in a LISTENING state?  I can do this with netstat
> -an -p tcp of course but I wanted to put this into a DLL function.
> I've tried playing around with the MFC CSocket class.  But I'm finding
> that calls to Create() and Listen() on the port will succeed on ports
> that are in the LISTENING state -- just not on ports with ESTABLISHED
> sessions.  I want to find a way to make sure that the port a user is
> allowed to select is not in a LISTENING state at all to hopefully
> preclude any conflicts later.  Thanks in advance!
> -Bill



Tue, 13 Sep 2005 21:09:15 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. How can I determine what process listen specified UDP or TCP port.

2. listening port?

3. Server daemons listening on ports

4. disable listen on Com port for a variable time

5. How to listen to a port < 1024

6. socket listening on multiple ports

7. Listen on any port?

8. How to listen on a port?

9. listen() with sockets and ports

10. How can i get local listening port list?

11. Listening to a COM port

12. Unable to listen on port 139

 

 
Powered by phpBB® Forum Software