I need to create a client and server program. The client will have a GUI that will display all the available servers (since more than one will be running) in a list box.
I’m guessing a TCP connection will be the best method here, but how will the client find the servers to connect to? I won’t know the IP address of the server because anyone could take the server program and run it on their computer and the client would have to find it.
Is there some way to make the server send some kind of signal that only the client application will be to connect to? So the server will be sending out a signal, the client finds the signal and connects to the server. Is this possible?
i also need to be able to store the IP address the client selects so when the client application is run again it will automatically connect to the server that was stored
Servers will need to identify themselves to one master server for which you know the IP address, then the client can ask that master server for the list of other servers.
To remember the last IP address, why not store it in the preferences/configuration file?
Servers will need to identify themselves to one master server
I would have the other servers contact the master server every minutes and say "hey, I exist!", and if the master server doesn't receive this from a server on the list after two minutes, then remove that server from the list until it contacts you again later.
ok so back to the question whats the best way to store the servers since now the master server and the client will need to able to store the ip address.
could you give more detail about a preferences/configuration file?
so how does the master server remember the server list?
well i don't want the client to connect to the last server it used.
I want to use a remember me check box so only if this is clicked the client will remember the server it used
and if the check box isn't clicked then the client needs to display all the servers again the next time the client app is run so the user can connect to a different server
so how does the master server remember the server list?
I don't understand what you want, why would it need to? It only needs to keep the list in memory.
beginner123 wrote:
well i don't want the client to connect to the last server it used.
I want to use a remember me check box so only if this is clicked the client will remember the server it used
and if the check box isn't clicked then the client needs to display all the servers again the next time the client app is run so the user can connect to a different server
Then do what I just said but only when the checkbox is ticked?
yes thats what i mean. how will the master server do this?
How would it not? You're the one programming it right? Surely you know off the top of your head how to maintain a list of IP addresses in C++? If not, I would like to know why you are starting such an ambitious project as this - if you don't even know about std::vector then I don't kow how you could know about TCP socket communication.
beginner123 wrote:
what kind of file should i use for storing the server in the client app?
What do you mean "what kind of file"? There is only one kind of file. If you mean "what format", then pick any you choose. It can even be as simple as just storing the plain-text IP address. The file extension does not matter, as it has no relation to the content of the file.
i can see that beginner123 have some experience in networking, probably not enough for such application, but still good.
in the same time, you are still a beginner in C++, and you want to create a network application.
here's one advice: start with the basics, and go from bottom up.
i'm not that great in networking, i just have some modest info:
the client can broadcast a request to know if there's a server in the local network or not, if a server catches this broadcast, it replies to the exact ip address that sent the broadcast telling it that "hey, i'm a server, what do you want", the connection can go on from this point as you see fit.
i myself admit "i can't write this program", it needs really some good experience in using tcp/ip protocol and broadcasting, and some programming knowledge.
security here is a great concern, that implies some cryptographic protocols, and functions for (hashing, communication encryption, credentials ...etc) they are so complicated.
i think my method can really apply to local networks or so, i don't think it works on the internet, like a client in Australia, and a server in the UK.