?
Solved

Server IP address

Posted on 2003-03-09
11
Medium Priority
?
339 Views
Last Modified: 2010-04-21
Hello Experts,
  Can anyone please give me the idea or code to get the server ip address.
Is there any inbuilt function. And later i would like to convert it into hexa and use it.
please do get back to me on this immediately.
Regards
Deepika
0
Comment
Question by:Deepikak
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +1
11 Comments
 

Author Comment

by:Deepikak
ID: 8101125
FYI
 I am coding in C++ and for the above mentioned i should be able to get something like
cae83f21   for the ip adress  202.232.63.33
Thanking you
Deepika
0
 
LVL 21

Expert Comment

by:tfewster
ID: 8101864
Which Unix? You can try:
grep `hostname` /etc/hosts
ifconfig -a  (man ifconfig, if your OS does not have the -a option)
0
 
LVL 21

Expert Comment

by:tfewster
ID: 8101882
Oh, and `netstat -in`; This should work with any Unix.

Your code may need to check if there is more than one IP address (E.g multiple NICs or multiple addresses bound to one NIC)
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 20

Expert Comment

by:Gns
ID: 8137420
I think Deepikak means from c/c++ tfewster.

You should probably be looking at the manpages for gethostbyname, gethostent, ntohl, ntohs, htonl and ntohs.

-- Glenn
0
 
LVL 5

Accepted Solution

by:
cryptosid earned 80 total points
ID: 8730756
hey deepika

good to see an indian unix programmer....

check this page:http://www.mcsr.olemiss.edu/cgi-bin/man-cgi?gethostbyname+3
0
 
LVL 20

Expert Comment

by:Gns
ID: 8730883
Thanks for providing a link to an incarnation of the manpage deepika should read (as I already mentioned;). Deepika should be reading his own systems manpage though, since any idiosyncrasies(sp?) are probably more likely to be documented there.

Also note that all this will get him/her is a long (or rather h_lenght (number of bytes) address) in network byte order, which he/she will then need convert to host byte order with ntohl, and finally (with some muckery, or just through simple printf's:-) to a string representation in hex (or... as said, just display it as hex).

-- Glenn
0
 
LVL 5

Expert Comment

by:cryptosid
ID: 8731041
chill dear Glenn ... i just happened to know these pages so i pasted the link... i guess deepika is intelligent enough to understand the complications involved.....each one of us is learning over here arent we...oops but one thing we won't learn here is to 'inculcate some politeness....' anyways kudos to u

Chill Glenn Chill
cryptosid
0
 
LVL 20

Expert Comment

by:Gns
ID: 8731103
Hey, I'm not trying to be impolite... Just a bit correct:-). And he really should be reading his own systems manpages, since the implementation of this part actually do vary... And since this qestion had been "dormant" for three months, I figured... If I was going to post anyway, why not spell it out:-).

Since it's raining here in Stockholm, I'm very much chilled down indeed (_not_ frosty;-).
In fact, I was never "heated up" at all.
Since I'm lacking my english dictionary, you might illuminate me as to the word "inculcate"... never heard that one (as one can guess from my location, I'm not a native to english).

-- Glenn
0
 
LVL 5

Expert Comment

by:cryptosid
ID: 8731725
ha ha ha...i mistook u for a rude all knowing expert...since you are hailing from stockholm i don't think your english is weak by any chance......good sense of humour u got....

for your kind reference:
http://dictionary.reference.com/search?q=inculcate

good to meet u
cryptosid

0
 

Author Comment

by:Deepikak
ID: 8736960
Hello
   I am sorry for this late response. I know this was posted by me long back and that I dint windup this question on the form. (Mr. cryptosid,  you helped a great deal in my learning phase).
My apologies for the inconvenience caused.
Regards
Deepika.
0
 
LVL 5

Expert Comment

by:cryptosid
ID: 8737660
anytime lady anytime...thanks for the points
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses
Course of the Month10 days, 9 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question