Finding a server's IP

Started by
2 comments, last by benjamin bunny 21 years, 9 months ago
I'm using winsock with a TCP connection over a LAN, and I need a way for a client machine to find out the server's IP address without it being specified manually. I've looked into multicasting (with UDP), but I can't get it to work on my network. There must be a standard way of doing this, but I can't find info on it. Any suggestions? ____________________________________________________________ www.elf-stone.com [edited by - benjamin bunny on July 25, 2002 10:30:23 AM]

____________________________________________________________www.elf-stone.com | Automated GL Extension Loading: GLee 5.00 for Win32 and Linux

Advertisement
Using TCP/IP, you could use the broadcast address to look for servers. The broadcast address is either 0 or 255 generally. (192.168.1.255 to broadcast to 192.168.1.x)

People used to use IPX for broadcast traffic as well (That''s how you played DOOM I on a Lan). It would work well in this case, if you think you can get your users to install it. It''s not so commonly present on windows PCs anymore.
Yes, broadcasting is the way. The broadcast address is dpendent on the IP address as well as the netmask. But Winsock gives you ways to do it. Just lookup the reference to Winsock on MSDN at the Microsoft site. Try looking up INADDR_BROADCAST and go from there.

You have to set the socket options for sending and recieving of broadcast packets (UDP only). Then send to the INADDR_BROADCAST address. The socket etup to recv briadcast packets will get them. Just reply to the address that send the packet


Stephen Manchester
Senior Technical Lead
Virtual Media Vision, Inc.
stephen@virtualmediavision.com
(310) 930-7349
Stephen ManchesterSenior Technical LeadVirtual Media Vision, Inc.stephen@virtualmediavision.com(310) 930-7349
Thanks for the replies. I''ve managed to get multicast to work, so I''ll stick with that for the time being, although I might change to broadcast later if it''s more likely to be supported.

____________________________________________________________www.elf-stone.com | Automated GL Extension Loading: GLee 5.00 for Win32 and Linux

This topic is closed to new replies.

Advertisement