|
-
Jun 6th, 2006, 10:09 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] [1.0/1.1] Validating a port number
Hi. I know how to validate a port number if it's in the min or max range. But how do you test for if the port number is being currently used?
-
Jun 6th, 2006, 11:38 AM
#2
Re: [1.0/1.1] Validating a port number
I don't think you can unless you write a component that works at the level a firewall would.
Ports can be used by multiple programs at once. You can have 1 FTP program connected to 3 seperate FTP server all utilizing Port 21.
Why would you need this?
-
Jun 6th, 2006, 01:38 PM
#3
Re: [1.0/1.1] Validating a port number
If you try to bind a TCP socket to a port that is already is associated with a TCP socket, it will fail. Same for UDP (I think). Of course, it might also fail for a myriad of other reasons.
Every passing hour brings the Solar System forty-three thousand miles closer to Globular Cluster M13 in Hercules -- and still there are some misfits who insist that there is no such thing as progress.
-
Jun 7th, 2006, 09:28 AM
#4
Thread Starter
Hyperactive Member
Re: [1.0/1.1] Validating a port number
i got the answer. Create a socket and bind onto the port using localhost as the ip address. If a SocketException is thrown then the port number is using. If ArgumentOutOfRangeException is thrown, then the port number is not between min and max.
Jennifer.
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
|