Archived

This topic is now archived and is closed to further replies.

gethostbyname is annoying me and so is winsock2

This topic is 5654 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hello ho fifoy. i am mister BABOON. i possess TWO questions in my brain. first.. i''m using winsock to write a silly server/client app.. and when i try to get my computer''s ip it''s all LOUSY coz it gives me my local network IP instead of my amazing INTERNET IP. A friend of mine got his amazing IP through my program and he doesn''t have local network at all. so what''s going on here?! help!! ok and for the second question... i wanted to do something with winsock 2, so like a normal person i #include <winsock2.h> and i tried to compile and got millions of baboon redefintion errors. If i inclued winsock2 b4 windows.h and i didn''t get them at all... but it''s ridiculous! what is going on here! DARN! ARGH! thanks for your help if you wanna help me and not sit and laugh on my ignorant message. May The Gzoo Be With You! ~Lord Gzoo

Share this post


Link to post
Share on other sites
quote:

baboon redefintion errors



ROFLMAO love it.

You probably get your local IP coz of ''gethostname'' returning actual IP of the interface instead of effective (ie mapped to internet) (or the opposite), did you look at all of the hosts returned? Your internet IP might be in there. Hence why your friend got his internet IP - only 1 interface.

As for the baboon redefinition errors, if it works #including only winsock2.h then that''s all you need do, don''t worry about it if you can get it working.

Share this post


Link to post
Share on other sites
quote:
hello ho fifoy. i am mister BABOON.

yet another example of why not to smoke crack

"I pity the fool, thug, or soul who tries to take over the world, then goes home crying to his momma."
- Mr. T

Share this post


Link to post
Share on other sites
ahh yes! err no.

thanks for the replies!

well i have PROGRESS! but i'm still baboon.
i get THREE ip's when i run my program on mr. computer 2 of them are lousy and one of them is the ip i want.
because i'm mentally ill i use the hostent structure and mr gethostbyname as i mentioned (did i?) to get the three ip's..
is there a way i can check if an ip that i found is the amazing ip or the lame network ip thing?

May The Gzoo Be With You!
~Lord Gzoo

[edited by - lord gzoo on June 23, 2002 10:42:38 AM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
First i''d like to ask why you need to figure out which IP is which, AFAIK it''s not neccessary to know which IP is connected to the net as far as running a sending/recving etc. it figures that all out itself.
Other than that, here is an idea that should work...
Discard any IP that has address 127.0.0.1 (this is loopback)
Discard any IP that has address starting with 192.168. (Class C? local area network address''s)
Discard any IP that has address starting with 10.0.0. (Class D? local area network address''s)
As long as a LAN is set up within the proper guidlines (using 192.168.*.* or 10.0.0.* addresses) This should get rid of the localhost loopback address (127.0.0.1) and any LAN addresses and leave you with the internet IP as the only remaining address if one exists.
There may be an easier way to do this, not sure, but once again i''ll say in the normal course of things, knowing which of your IP''s is connected to the net isn''t neccessary, as when you bind to a port, you just bind to any IP address. Of course you probably have a different use for wanting to know the IP.

Share this post


Link to post
Share on other sites
hoi

mmm... so if i get an ip starting with 192.168 or 10.0.0 i should kill it with power you say...

a normal network setup should use this thingies? coz if not it''s not lovely. but as i understood from your message the network setup thing should use these ip kak... so it IS lovely.

thanks thanks

May The Gzoo Be With You!
~Lord Gzoo

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
the 192.168.*.* and 10.0.0.* network addresses are reserved for LAN addresses. You are only meant to use network addresses other than these if you have actually requested them from whatever company it is that hands out network addresses

Share this post


Link to post
Share on other sites
Why do you need to know the "amazing" IP address anyway? There aren''t many cases where it''s needed... That''s not to say you haven''t found one of course, but if it''s just a simple client/server app then there''s probably no need.


codeka.com - Just click it.

Share this post


Link to post
Share on other sites