Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have a project that requires a client app to communicate with a server. I was

ID: 644443 • Letter: I

Question

I have a project that requires a client app to communicate with a server. I was wondering if there is a way for the client app to detect available servers and "know" by some method or another which server is the one it needs.

The client is built with .net and c#, the server is a simple SQL database.They are on the same network.

Is there a built in mechanism to do this or is the task more complex then it seems at first?

I don't have more details ATM, it's still just an idea. The reason behind it is that when a user uses the client app, we don't want him to enter connection strings manually if he doesn't have to.

Explanation / Answer

I can think of three main solutions to the issue:

Send a message to the network's broadcast address on a well-known port. Your same-network server picks this up and sends a reply to the source address ("I'm here at: ...").

Make your server occasionally send a message to the broadcast address on a well-known port, once every so many seconds. Clients can listen for this and then connect.

Have a master server responsible for coupling the two: the server sends "I'm not dead yet" packages to the master; client connects to master and gets a server list. (*) I don't recommend this.

1 and 2 are essentially the same, but with active (1) or passive (2) scanning. 1 seems cleaner on the network; 2 is probably a little easier to implement.

(*) This is a lot more hassle and requires another server on a well-known address, and represents a single point of failure, but it can solve discoverability issues.