GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 02-Jan-2007, 01:00
kmathanbe kmathanbe is offline
New Member
 
Join Date: Dec 2006
Location: india
Posts: 12
kmathanbe is on a distinguished road
Post

get the local host ip in unix os


Dear's

how r u ?

i am using unix os. already i wrote one small code to get the local ip address, but it display the unix server ip address. so, how can i get my local pc ip addressin c++ program. please give me the code to get the ip(only unix os).
  #2  
Old 02-Jan-2007, 10:13
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 4,688
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: get the local host ip in unix os


Quote:
Originally Posted by kmathanbe
how can i get my local pc ip

There are no standard C (or C++) library functions that deal with issues of network interfaces or ip addresses or any other hardware-dependent system properties.

One function that is commonly available is getifaddrs(). Check to see if your system has it. There may or may not be a man page for it. If not, then you can look for information on the web.

Note that this gets a list of structs that contain, among other things, ip addresses for all interfaces (including localhost), so you may have to do a little work to dig out the pertinent information.

Also, note that the versions that I have used only worked for IPv4, and I haven't followed recent developments to see what has been done for IPv6, so if you require complete information for IPv6 you might have to try something else.

Also note that I don't have any UNIX systems to allow me to verify anything you might come up with or to answer any specific questions.

It is likely that other people might have such systems, but to expect meaningful responses, you might consider telling exactly what UNIX system you are using (and what compiler, since some systems have very crippled compilers, and some have complete gcc or other installations). These things (library functions, etc.) are system-dependent.

Regards,

Dave
  #3  
Old 02-Jan-2007, 21:46
kmathanbe kmathanbe is offline
New Member
 
Join Date: Dec 2006
Location: india
Posts: 12
kmathanbe is on a distinguished road
Post

Re: get the local host ip in unix os


hi,

thx ur reply. i am using Sun Solaris 10. compiler is CC only. not accept the g++ or gcc.
 
 

Recent GIDBlogMore photos on Flickr by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Looking for a free host with phpBB support Riamus Free Web Hosting 6 22-Oct-2006 18:30
Host Color: Host Up To 10 Web Sites And Get Your Free .EU , .Ca or .Us Domain Name fcolor Web Hosting Advertisements & Offers 0 12-Jun-2006 07:43
Host Unlimited Sites $19/year. Hot Hot Hot!!! nethostspace Web Hosting Advertisements & Offers 1 12-Jan-2006 19:20
access local webserver from the local host calisro Apache Web Server Forum 1 10-May-2004 08:53
Before posting a web host review - PLEASE READ JdS Web Host Review Forum 0 16-Oct-2003 09:28

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 20:50.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.