• Advertisement

Archived

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

getting your ip

This topic is 6248 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

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

  • Advertisement