How to check port can be shared in WCF

1k Views Asked by At

I have client-server app, which is using WCF port sharing feature for communication between each other. In case, when I installing both parts on the same machine I need to use the same port. The question is, how can I distinguish during installation, is some port is busy or used by another part of my app and can be shared.

Any suggestions? Many thanks.

2

There are 2 best solutions below

0
On

You can use telnet to check if a port is busy.

For windows Go to startpanel and type cmd then type

C:>telnet localhost 52753

or any other portnumber then 52753. If you have a web server running, you will go on to a blank screen if using port 80 and typing: C:>telnet localhost 80

If a port is not in use then a message will tell you that the connection failed.

3
On

To do it in code... look at this question...

In C#, how to check if a TCP port is available?

That should get you there...