[gameprogrammer] "Network Byte Order" IP's to dotted-triplet format

  • From: Jake The Snake Briggs <jacob_briggs@xxxxxxxxxxxxxxx>
  • To: gameprogrammer@xxxxxxxxxxxxx
  • Date: Thu, 11 Nov 2004 09:58:41 +1300

Hi all
I need to get the IP address of a socket. I am writing a multiplayer 
game, basicly its "snake", but multiplayer. I want to write 3 programs, 
a client game, a server, and a master server. I want to be able to tell 
the master server to give me a list of all the game servers that are 
registered with it. So far i have a crappy game server written, that can 
register with the master server. I have a really crappy game client 
written. I have the simple master sever 95% finished, and thats where my 
problem lies.
I am using this function :

IPaddress *NET2_TCPGetPeerAddress(int socket);

because i am using Bob Pendletons NET2_SDL library. This fills the 
specified IPaddress struct with the IP and Port of the socket in 
"Network Byte Order" format. So i think (after a bit of googleing) i 
understand what that is, and why its used.
At the moment i can go
telnet <masterserverip> <masterserverport>
then type
"servers"
and i get back a list of server ip's and ports. But I want them to be 
the dotted triplet format, like 192.168.0.2 rather than 18328373673 or 
whatever it is. How would one go about transforming Network Byte Order 
to dotted format?



---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html


Other related posts: