Jlouro
Jlouro

Reputation: 4545

Detected if a machine is connected/Available?

How can I detect if a machine is connected/available in the present network.

It has several uses of course, but my main concern here is that my application uses resources located in specific machines and if they are not available it will not even attempt the connection and will use local resources.

Upvotes: 5

Views: 2108

Answers (4)

user207421
user207421

Reputation: 310893

Just try to use the resource and if you get an error use the local resource instead. The strategy you are trying to implement suffers from several problems including timing windows between the test and the use, during which the resource may become unavailable, and also doesn't actually test the resource for availability, only some lower-order thing like a TCP port or the ICMP echo part of the stack. In general the best way to detect whether a resource is available is just to try to use it, and recover from the failures. You have to write code to handle those failures anyway, why do it all twice?

Upvotes: 2

mjn
mjn

Reputation: 36654

A different strategy than trying to connect: let the server tell the clients if the services are still available, by sending UDP Broadcast or some kind of heartbeat signal over middleware (pipes?), which the clients listens to - a publish/subscribe communication model.

Upvotes: 0

Dave Rager
Dave Rager

Reputation: 8150

ICMP echo request (PING) will tell you if the machine is up and reachable on the network. It will not tell you if the service you want to connect to is available on the machine (up and running).

Best bet would probably be to just attempt the connection and fall back to local resources if the connection fails.

Upvotes: 3

RRUZ
RRUZ

Reputation: 136391

you can try making a ping to the machine. check this article Making a PING with Delphi and the WMI.

Upvotes: 6

Related Questions