Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Detecting Internet Disconnection


    I am writing a chatting program and want to receive the notification on Internet disconnection (e.g. when the cable is unplugged). Is there any way to achieve this? Thanks in advance!

  2. #2
    Linux Engineer Kloschüssel's Avatar
    Join Date
    Oct 2005
    Wouldn't it be enough to determine:

    "Packets not sent => no connection"

    The concrete implementation depends on the kind of communication you have. If it is centralized you can either have "server down" or "internet disconnect", if it is decentralized it's either "peer down" or "internet disconnect", where "internet disconnect" is somewhat alike "all peer down".

    Another, and probably the "cheapest" implementation would be a ICMP ping to a server that is always up (i.e. 8.8.8.. But it is also the implementation that is the least related to your software. If is down it doesn't necessarily mean your software can't work anymore.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts