Advertisement

gethostbyname is annoying me and so is winsock2

Started by June 23, 2002 08:10 AM
6 comments, last by zngb 22 years, 7 months ago
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
--Amir
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.
Advertisement
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
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]
--Amir
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.
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
--Amir
Advertisement
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
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.

This topic is closed to new replies.

Advertisement