views:

371

answers:

2

I wish to have two classes, a server class and a client class. The server class should recieve the IP address and Port number of each new client and store them in a list. It should supply each of the clients with a list of connected clients and their IP addresses. The clients could then communicate with each other using TCP connections.

The catch is that the clients won't know what the IP address of the server is. The entire program will however run on a local area network. My guess is that it needs some sort of UDP broadcast, but every time I try to impliment this it doesn't work unless the two instances of the program are running on the same computer.

The application would be installed by clients with limited computing knowledge so it should just be a case of installing the program on all the computers and plugging in to the network.

If anyone has a reliable, clear implimentation of this using C#.net 3.5 or earlier it would be much appreciated.

+1  A: 

Not sure if this will help you - but you could use WCF and .NET 3.5

RandomNoob
I will look into it, it may do some of what I'm after, the only issue I have with it is that the article suggests that many of those things will only work in windows vista
Tuskan360
This is the best I've had so far, I don't really like it as a solution since it requires the user to explicitly click to accept, I would prefer if that could be handled internally in my application rather than by windows's People Near Me applicaion. Also I'm struggling to make it work effectively when both computers have the applicaiotn already open and running.
Tuskan360
+1  A: 

You may or may not want to use the Lidgren network library, but the source code is available and it does udp broadcast for server discovery for you to check out.

lidgren
This seems to work perfectly, addapting the source code from the peer to peer sample and using the Peer.DiscoverLocalPeers to find and connect to computers on the LAN.
Tuskan360