LinuxQuestions.org
Visit Jeremy's Blog.
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 02-26-2005, 04:22 PM   #1
tbruer1138
LQ Newbie
 
Registered: Feb 2005
Posts: 5

Rep: Reputation: 0
Network status from C/C++ program


What networking/system calls can be used to determine if the machine my software is running on is connected to the network? We are using sockets to do HTTP comms but have discovered no way to get the network status, for instance, when someone disconnects the network cable or the network goes down. Any suggestions/ideas/recommendations will be greatly appreciated!
 
Old 02-26-2005, 05:00 PM   #2
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,290

Rep: Reputation: 378Reputation: 378Reputation: 378Reputation: 378
This is heavily dependent on the OS you're running. In Unix based systems you can issue various ioctls to various network devices to see their status (not sure on all the exact details). There are a couple of quick and dirty ways to try to do this though, such as using popen to run ifconfig and then parsing the output or trying to ping a remote host.

Usually with nextwork programs, you just try to do a bind/accept or connect (depending on whether you're a server or a client) with your socket, and if it doesn't work report the error to the user.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Webmin Server Status + Bash program to bring Apache up xbaez Programming 2 11-14-2005 07:57 AM
get exit status from a C-program in Bash Yoko Programming 1 07-12-2005 04:33 PM
Linux program to determine Win XP login status andrej666 Programming 2 03-08-2005 09:40 AM
Need program to show cpu usage, network status and stuff in X....any sugestions? op_stager Linux - Software 3 09-24-2004 07:56 AM
Program that shows status of CPU, Ram etc... face_master Linux - Software 2 04-01-2003 12:38 AM

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

All times are GMT -5. The time now is 04:10 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