|
-
Mar 14th, 2004, 12:37 PM
#1
Thread Starter
yay gay
How to check if a given port is in use?
I am developing an irc bot and i am making the DCC part thing. I need to check if a given port is being used or not.
Is there any built in function to check that? Thanks
\m/  \m/
-
Mar 14th, 2004, 01:51 PM
#2
Frenzied Member
Not sure if there's a built in function, but I've always tried to connect, and catch the exception if it's already in use.
-
Mar 14th, 2004, 04:55 PM
#3
Sleep mode
-
Mar 14th, 2004, 07:13 PM
#4
Frenzied Member
Ha! Forgot about that.
But I tell you, here's the rub:
If you want your code to establish a connection, you better be prepared to handle anything that goes wrong. I mean, even if you check first to see if a port is in use, it does NOT mean (even if it's just a few milliseconds later) that that particular port is available.
So why bother to check the status before you attempt to connect? For robust code, you're going to have to handle the exception anyway. Might as well cut to the chase and try to connect anayway.
Just my opinion 
Mike
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|