Open computers on the local network with a specific open port using .NET.

I need to "discover" the local computers that my WCF Windows service is running on, so I can talk to them. Right now you need to manually enter the ipaddress: port command, but I would like to have an application (web?) That monitors the machines running the service and reports it.

When I try to connect to the wrong ip / port, it takes "forever" before the timeout, so it is impractical to check all ip on my local network. Is there a quick way to find out which machines open a port (they all have a hole in the firewall for that particular port).

TIA

+4
source share
3 answers

I have done this several times. Just set the timeout value very low.

In addition, if its a real machine, but without opening a port, it still does not work. If you are doing a subnet count, then yes, you should have (say) a 1 second timeout.

Multithreading is a fun thing to code

edit: I can not find my code. here is a link to a solution from someone else

http://social.msdn.microsoft.com/forums/en-US/netfxnetcom/thread/c8161442-61b5-4840-999b-5bb36bda0b6d/

+4
source

Can you have a client configured to contact the web application and let it know that it uses your wcf service?

which requires the web application to run on a known computer that does not change.

+1
source

Why don't they use multicast to send the HELLO packet so often. This assumes, of course, that multicast is available in your scenario and you are not talking in routing domains. Just use the contents of the "HELLO" package, for example, the unicast ipv4 address, so you know what you should talk to. Of course, you do not need to use multicast, you can just send the broadcast to 255.255.255.255, which is not a difficult task, and then listen to these messages. The advantage of this is that you can also allow port negotiations. For example, if your application usually associates with a port, but this port is not available, it can automatically select a port and tell you which port it is bound to. Avoids manual configuration of configuration and headaches. Damn, he can even use the broadcast to send a message and check if he got it. If this is not the case, run a warning informing the system administrator. I use something in these lines to control test harnesses for soft switches (voice) and it works very well. Of course, I could be very on that. Just think about the box here.

+1
source

Source: https://habr.com/ru/post/1300254/


All Articles