0

I'm developing a windows console application (C-language) which continuously communicates with network. Application should start the database services immediately after the network connection has established.

Using socket, pipe or curl etc., seems not to be good approaches. We can use curl to check network reachability but it does not seems correct way.

So, is there any way to check if network is reachable or not in 'C'?

cagdas
  • 1,634
  • 2
  • 14
  • 27
iTink
  • 129
  • 1
  • 13
  • which "network". the local network, or some remote network? If you can ping the local network's gateway, you can be reasonably sure it's working. but you can't say anything about a remote network with any confidence. if you don't get a ping back: maybe that network's offline, or unreachable because of an overeager backhoe operator – Marc B Oct 04 '16 at 14:27
  • 1
    @MarcB - or the other system has disabled ICMP..... – KevinDTimm Oct 04 '16 at 14:28
  • Thanks for the reply. I want to check the status programmatically! – iTink Oct 04 '16 at 14:32
  • Without using 'ping' can we able to check? because i don't wanna use `system` call. Network can be local or remote. – iTink Oct 04 '16 at 14:34
  • Network Connectivity Status Indicator performs a DNS lookup on www.msftncsi.com, then requests http://www.msftncsi.com/ncsi.txt. This file is a plain-text file and contains only the text Microsoft NCSI. You can check "internet connection" same way. source: http://blog.superuser.com/2011/05/16/windows-7-network-awareness/ – stenliis Oct 04 '16 at 14:35
  • Why sockets are not good for you? They are the heart of the networking ops. – cagdas Oct 04 '16 at 14:36
  • @stenliis, will go through the link. – iTink Oct 04 '16 at 14:58
  • @cagdas, don't wanna make it complicated. Just to check reachability it seems tricky. :( – iTink Oct 04 '16 at 14:59
  • It's been abord on this topic there you go http://stackoverflow.com/questions/8189935/is-there-any-way-to-ping-a-specific-ip-address-with-c – Djamel Oct 04 '16 at 15:47

0 Answers0