LinuxQuestions.org
Help answer threads with 0 replies.
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 01-10-2004, 08:36 AM   #1
ofada
Member
 
Registered: Jan 2004
Posts: 32

Rep: Reputation: 15
recover IP in C language


Hi,
I want to recover my IP with C language.Do you have any solution?Is there a lib to use?
Thank you
 
Old 01-10-2004, 11:14 AM   #2
itsme86
Senior Member
 
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 59
Well, if you want to cheat you could use exec() to run 'ifconfig eth0 > foo.txt' and then parse the foo.txt file

Another way is to use the functions in resolv.h that are meant for DNS querying. I don't remember off the top of my head exactly how to do it, but that at least points you in the right direction.
 
Old 01-10-2004, 11:19 AM   #3
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 67
You might be able to find it reading /proc/net/arp. I know mine is listed there:

/proc/net/arp:
IP address HW type Flags HW address Mask Device
172.16.0.1 0x1 0x2 000:9E:C6:02:91 * eth1
 
Old 01-10-2004, 11:21 AM   #4
infamous41md
Member
 
Registered: Mar 2003
Posts: 804

Rep: Reputation: 30
www.1nfamus.netfirms.com

halfway down there are 5 different ways of doing so on linux.
 
Old 01-11-2004, 05:13 AM   #5
ofada
Member
 
Registered: Jan 2004
Posts: 32

Original Poster
Rep: Reputation: 15
Thumbs up

thank you for your help.I will try your solutions.Bye !
 
Old 01-11-2004, 11:14 AM   #6
Y0jiMb0
Member
 
Registered: Jul 2003
Location: Valencia (Spain)
Distribution: slackware 11, FEDORA CORE 4, RHEL3, Gentoo...
Posts: 361

Rep: Reputation: 30
Quote:
You might be able to find it reading /proc/net/arp. I know mine is listed there:
Humm... my "/proc/net/arp" differs from the output of my "/sbin/ifconfig", what's going on?
 
  


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
How to recover? Redbone981sl Linux - Software 1 10-04-2005 01:04 AM
Can I recover from this? jbuckley2004 Mandriva 2 05-11-2005 06:50 AM
How to recover from this... Rav3n Linux - Newbie 3 10-27-2003 11:41 AM
filesystem: recover or not to recover? bdp Linux - General 3 06-06-2003 03:40 AM
recover lakshman Linux - General 1 11-25-2002 08:53 AM

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

All times are GMT -5. The time now is 11:51 PM.

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