VB6 - Winsock, Auto find server using UDP Broadcast (LAN ONLY)
I attached a Client and a Server program, a simple Chat program demonstrating how to connect to the server without knowing the server's IP.
This is done by broadcasting a message from the client to the entire network, when server receives the message, server will broadcast another message giving it's IP and port number to use to connect to it. When client receives the server's message, it knows where to connect to using TCP connection.
Here's Pseudo code on what's going on (the messages that are sent back and forth)
Client broadcasts: "Where are you ?" (Could be anything, this is just an example)
Server receives message
Server broadcasts: "IP=192.128.0.1, Port=8888" (the IP and port # are just examples)
Client receives server's message, and knows where to connect to
Client connects to server using TCP