tags:

views:

646

answers:

3

I want to develop simple Serverless LAN Chat program just for fun. How can I do this ? What type Architecture should I use?

Last year I have worked on TCP,UDP Client/ Server application Project.It was simple (Server listens to certain port/socket and Client connect to server's port etc..) But I have no idea about how to develop "Serverless" LAN Chat program. How can I do this? UDP,TCP,Multicast,Broadcast? or Should program behave like both server and client?

+6  A: 

The simplest way would be to use UDP and simply broadcast your messages all over the network. A little bit more advanced version would be to only use the broadcast to discover other nodes in the network.

  • Every node maintains a list of known peers.
  • Messages are sent with TCP to all known peers.
  • When a node starts up, it sends out an UDP broadcast to discover other nodes.
  • When a node receives a discovery broadcast, it sends "itself" to the source of the broadcast, in order to make it self known. The receiving node adds the broadcaster to it's own list of known peers.
  • When a node drops out of the network, it sends another broadcast in order to inform the remaining nodes that they should remove the dropped client from their list.

You would also have to consider handling the dropping out of nodes without them informing the rest of the network.

Stefan Schmidt
+1  A: 

The spread toolkit may be a bit overkill for what you want, but an interesting starting point.

From the blurb:


Spread is an open source toolkit that provides a high performance messaging service that is resilient to faults across local and wide area networks. Spread functions as a unified message bus for distributed applications, and provides highly tuned application-level multicast, group communication, and point to point support. Spread services range from reliable messaging to fully ordered messages with delivery guarantees.

Spread can be used in many distributed applications that require high reliability, high performance, and robust communication among various subsets of members. The toolkit is designed to encapsulate the challenging aspects of asynchronous networks and enable the construction of reliable and scalable distributed applications.

Spread consists of a library that user applications are linked with, a binary daemon which runs on each computer that is part of the processor group, and various utility and demonstration programs.

Some of the services and benefits provided by Spread:

  • Reliable and scalable messaging and group communication.
  • A very powerful but simple API simplifies the construction of distributed architectures.
  • Easy to use, deploy and maintain.
  • Highly scalable from one local area network to complex wide area networks.
  • Supports thousands of groups with different sets of members.
  • Enables message reliability in the presence of machine failures, process crashes and recoveries, and network partitions and merges.
  • Provides a range of reliability, ordering and stability guarantees for messages.
  • Emphasis on robustness and high performance.
  • Completely distributed algorithms with no central point of failure.
frankodwyer
Does Spread do anything to tackle issue with NAT?
Greg Dean
A: 

Apples iChat is an example of the very product you are envisioning. It uses Bonjour (apple's zero-conf networking protocol) to identify peers on a LAN. You can then chat or audio/video chat with them.

I'm not entirely sure how Bonjour works inside, but I know it uses multicast. Clients "register" services on the LAN, and the Bonjour protocol allows for each host to pull up a directory of hosts for a given service (all without central management).

jdizzle