# Check online

**URL:** <https://forum.xojo.com/t/check-online/48802>\
**Category:** Getting Started\
**Created:** [June 1, 2019, 10:38am UTC](https://forum.xojo.com/t/check-online/48802 "2019-06-01T10:38:01Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nathan\_Wright](https://forum.xojo.com/user_avatar/forum.xojo.com/nathan_wright/32/575_2.png) [@Nathan\_Wright](https://forum.xojo.com/u/Nathan_Wright)\
**Post date:** [June 1, 2019, 10:38am UTC](https://forum.xojo.com/t/check-online/48802/1 "2019-06-01T10:38:01Z")

</div>

I need a way to have an event fire when a desktop app is online/offline, is their anything in Xojo that would tell me this or some other way of knowing?

---

<div class="post-metadata">

**Author:** ![Greg\_O\_Lone](https://forum.xojo.com/user_avatar/forum.xojo.com/greg_o_lone/32/49_2.png) [@Greg\_O\_Lone](https://forum.xojo.com/u/Greg_O_Lone)\
**Post date:** [June 1, 2019, 11:21am UTC](https://forum.xojo.com/t/check-online/48802/2 "2019-06-01T11:21:05Z")

</div>

The easiest way is to periodically check if you can reach a few websites. For instance,

`api.ipify.org
www.example.com`

---

<div class="post-metadata">

**Author:** ![Guido\_Boller](https://forum.xojo.com/letter_avatar_proxy/v4/letter/g/3ec8ea/32.png) [@Guido\_Boller](https://forum.xojo.com/u/Guido_Boller)\
**Post date:** [June 1, 2019, 11:42am UTC](https://forum.xojo.com/t/check-online/48802/3 "2019-06-01T11:42:01Z")

</div>

My preferred way is to use the HTTPSocket.GetHeader method. As long as the result is Nil, you’re offline. To be on the safe side, I usually do this with two different websites.

---

<div class="post-metadata">

**Author:** ![Jean-Yves\_Pochez](https://forum.xojo.com/user_avatar/forum.xojo.com/jean-yves_pochez/32/21769_2.png) [@Jean-Yves\_Pochez](https://forum.xojo.com/u/Jean-Yves_Pochez)\
**Post date:** [June 1, 2019, 12:10pm UTC](https://forum.xojo.com/t/check-online/48802/4 "2019-06-01T12:10:42Z")

</div>

from : [https://forum.xojo.com/36891-best-way-to-determine-internet-connection-vote-advice](https://forum.xojo.com/36891-best-way-to-determine-internet-connection-vote-advice)

```auto
Public Function IsInternetConnected() as Boolean
  ' checks if internet is connected by checking the connection to google,apple and microsoft
  ' fastest way found today
  ' see https://forum.xojo.com/36891-best-way-to-determine-internet-connection-vote-advice
  
  Dim http As New TCPSocket
  
  http.Address = "www.apple.com"
  http.port = 80
  http.Connect
  dim okapple as Boolean = (http.LastErrorCode = 0)
  http.close
  
  http.Address = "www.google.com"
  http.Connect
  dim okgoogle as Boolean = (http.LastErrorCode = 0)
  http.close
  
  http.Address = "www.microsoft.com"
  http.Connect
  dim okmicrosoft as Boolean = (http.LastErrorCode = 0)
  http.close
  
  Return okapple and okgoogle and okmicrosoft
  
End Function
```

---

<div class="post-metadata">

**Author:** ![Nathan\_Wright](https://forum.xojo.com/user_avatar/forum.xojo.com/nathan_wright/32/575_2.png) [@Nathan\_Wright](https://forum.xojo.com/u/Nathan_Wright)\
**Post date:** [June 1, 2019, 2:25pm UTC](https://forum.xojo.com/t/check-online/48802/5 "2019-06-01T14:25:53Z")

</div>

Thanks everyone

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [April 29, 2021, 3:57pm UTC](https://forum.xojo.com/t/check-online/48802/6 "2021-04-29T15:57:44Z")

</div>


