Skip to main content
gamedev.net
🔒 Locked

getting your ip

Started by djsteffey 4 replies 550+ views
Original Post
djsteffey
djsteffey
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
Thr33d
Thr33d
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
Wglc_
Wglc_
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
djsteffey
djsteffey
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

logicpill
logicpill
I think you should be able to use one of the gethost or gethostby functions to to decompose the ip.
Anderoth
Anderoth
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

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.