LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-27-2006, 01:53 AM   #1
ggeorgak
LQ Newbie
 
Registered: Aug 2006
Posts: 7

Rep: Reputation: 0
Check network connectivity


Is there a way to check if there is network connectivity in a C/C++ program?
 
Old 08-27-2006, 02:13 AM   #2
slantoflight
Member
 
Registered: Aug 2005
Distribution: Smoothwall
Posts: 283
Blog Entries: 3

Rep: Reputation: 35
Yes. There are many ways for you to check activity, in variety of situations and operatings systems. You can check for wifi activity, bluetooth activity, serial activity, ethernet activity, even 1394 activity. You can even test what sites the person has visited or hasn't visited, like www.google.com for instance. You can do anything with C++


With C++, you can.
 
Old 08-27-2006, 03:04 AM   #3
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
And of course, you can do it too in C.
 
Old 08-29-2006, 02:17 AM   #4
ggeorgak
LQ Newbie
 
Registered: Aug 2006
Posts: 7

Original Poster
Rep: Reputation: 0
Yes, googling was the first thing I tried but didn't find anything for linux. Could you more specific?
 
Old 08-29-2006, 02:50 AM   #5
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
I believe you are the one needing to be more specific.

What kind of connectivity test are you looking for ?
 
Old 08-29-2006, 06:20 PM   #6
ggeorgak
LQ Newbie
 
Registered: Aug 2006
Posts: 7

Original Poster
Rep: Reputation: 0
Ok, argument accepted. What I want to do is to change the ftp client code to do the following (assuming I would like to download a file from a wireless node):

1) Check if there is connectivity with that node
2) Well if there isn't sleep for let's say 10ms and check again

Simply a while(!not_connected()) { sleep(some_time); }

What I just thought now is that I could send a ftp start session command and check if the send() func of the TCP conn fails. This is the specific part.

More generally, in win programming there is a GetInternetConnectivity() func that returns true if the computer is connected the internet. Is there some same functionality in linux (syscall?) or a workaround that does tha same. jilliagre thanks for your interest.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Connectivity check, quickly, in a script jlangelier Linux - Newbie 6 12-19-2004 10:19 PM
Can't get network connectivity skint Linux - Networking 15 12-19-2004 02:30 PM
Network Connectivity inescapeableus Linux - Networking 0 11-28-2004 03:53 PM
No network connectivity beyond network card linux8 simplimarvelous Linux - Networking 1 02-18-2003 10:22 PM
No Network Connectivity dwest576 Linux - Networking 6 12-04-2002 01:59 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:18 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration