LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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-22-2005, 12:55 PM   #1
eric_pena
LQ Newbie
 
Registered: Aug 2005
Posts: 1

Rep: Reputation: 0
Read and display the my own IP address in C?


I need to write a small program in C that gets and then displays my own IP address.

I'm new on Linux, although I have a little experience on other OS.
Any help will be really appreciated!
 
Old 08-22-2005, 01:59 PM   #2
rstewart
Member
 
Registered: Feb 2005
Location: Sunnyvale, CA
Distribution: Ubuntu
Posts: 205

Rep: Reputation: 38
Do a google search on "SIOCGIFADDR". That ioctl will return information based upon the interface specified. There are a number of examples using the ioctl that the google search will report.
 
Old 08-22-2005, 06:54 PM   #3
primo
Member
 
Registered: Jun 2005
Posts: 542

Rep: Reputation: 34
There's gethostname(3) too
Then with gethostbyname(3) you get the IP

The ioctl()'s are useful on a multi-homed host
 
Old 02-09-2006, 09:29 PM   #4
Madhusudhan
LQ Newbie
 
Registered: Feb 2006
Posts: 10

Rep: Reputation: 0
using ioctl we can do it...
infact you can get entire program itself in LinuxQuestions.org > Forums > Non-*NIX Forums > Programming forum....
name of the Post is "read IP address in C module progarm" by linux_lover2005.
 
  


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
read IP address i nC module progarm linux_lover2005 Programming 1 02-10-2005 09:22 PM
Cyrus Remote ADdress book read only dlublink Linux - Networking 0 01-19-2005 02:35 PM
read gateway address from C program cranium2004 Programming 6 11-20-2004 06:20 PM
read other posts but still can't change display pires Linux - Newbie 5 08-25-2003 09:30 AM
display ip address of client on webpage joe_stevensen Programming 4 07-22-2003 06:30 PM

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

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