getting your ip

Started by
4 comments, last by Anderoth 23 years, 3 months ago
is there a function i can call to retrieve my ip address. I want to be able to do this in game so I can show the user his/her ip address. I know how to get it using winipcfg but that is from the run command in windows. I want to do this in game and store the ip in a char string like char ip[20] = "127.0.0.1"; "Now go away or I shall taunt you a second time" - Monty Python and the Holy Grail We are creating a Multi-player space strategy/shoot-em-up/RPG game. Development is well under way and we do have a playable demo. Always looking for help. Digital Euphoria Soft
Advertisement
sorry - not an answer but, just wanted to mention, i''m also looking for the answer to this. If i find it anywhere before you/we get a reply - i''ll post it


thanx
-mike
I think what you''re looking for is gethostname() in winsock.h. It takes a character pointer to store the address and an integer for its length.

Hope that helps,
Wglc
that is almost right.......
that returns to me the name of my computer on our university network
what i am looking for is the actual ip address
ie
"123.123.123.123" os whatever


"Now go away or I shall taunt you a second time"
- Monty Python and the Holy Grail
We are creating a Multi-player space strategy/shoot-em-up/RPG game.
Development is well under way and we do have a playable demo.
Always looking for help.
Digital Euphoria Soft

I think you should be able to use one of the gethost or gethostby functions to to decompose the ip.
LPHOSTENT thisputer;
char FAR * hname = "";
gethostname(hname,sizeof(hname));
thisputer = gethostbyname(hname);
thisaddy = ((LPIN_ADDR)thisputer->h_addr_list[0]);
sprintf(test,"Your IP is: %s.",inet_ntoa(*thisaddy));

hope it''s usefull



www.bloodlore.com
www.bloodlore.com

This topic is closed to new replies.

Advertisement