Developing a serverless chat program Lan!

I want to develop a simple serverless LAN chat program just for fun. How can i do this? What type of architecture should I use?

Last year, I worked on the TCP / UDP Client / Server Project.It project was simple (the server listens on a specific port / socket, and the client connects to the server port, etc.). But I have no idea how to develop a โ€œserverlessโ€ LAN chat program. How can I do this? UDP, TCP, Multicast, Broadcast? Or Should the program behave like a server and client?

+6
udp tcp
source share
3 answers

The easiest way is to use UDP and simply relay your messages across the network. A slightly more advanced version will only use broadcast to detect other nodes on the network.

  • Each node maintains a list of known peers.
  • Messages are sent with TCP to all known nodes.
  • When node starts, it sends a UDP broadcast to detect other nodes.
  • When a node receives a discovery broadcast, it sends itself to the broadcast source to make it self-known. The receiving node adds the broadcaster to its list of well-known peers.
  • When a node drops out of the network, it sends another broadcast to inform the remaining nodes that they should remove the remote client from their list.

You will also need to consider removing drop-down nodes without informing the rest of the network.

+10
source share

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

From the commercial:


Spread is an open source toolkit that provides a high-performance messaging service that is error-resistant on local and global networks. Distributed as a single messaging bus for distributed applications, it provides highly-tuned application-level multicast, multicast, and point-to-point support. Common services range from reliable messaging to fully ordered messages with delivery guarantees.

Distribution can be used in many distributed applications that require high reliability, high performance, and reliable communication between different subsets of members. The toolkit is designed to encapsulate the complex aspects of asynchronous networks and create robust and scalable distributed applications.

Distribution consists of a library with which user applications are associated, a binary daemon that runs on each computer that is part of a group of processors, and various software and demo programs.

Some of the services and benefits provided by Spread are:

  • 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.
  • High scalability from one local network to complex wide area networks.
  • Supports thousands of groups with different sets of elements.
  • Provides reliable messages in the event of equipment failures, process failures, and recovery, as well as network partitions and mergers.
  • Provides a number of guarantees for the reliability, ordering and stability of messages.
  • Emphasis on reliability and high performance.
  • Fully distributed algorithms without a central point of failure.
+1
source share

IChat apples are an example of the product you are proposing. It uses Bonjour (apple zero-conf network protocol) to identify peers on the local network. Then you can chat with the audio or video chat.

I'm not quite sure how Bonjour works internally, but I know that it uses multicast. Clients โ€œregisterโ€ services on the local network, and the Bonjour protocol allows each host to pull up the host directory for this service (all without centralized management).

0
source share

All Articles