Meet Simplechat: Live Chat From Your Phone

The Chat Application is very common today offered either via a web application or mobile application. Learning to write a Chat Application is good for understanding many network communication concepts and can be useful to build other network applications. Chat Application provides communication between two parties i.e. sender and receiver. The sender is someone who initiates and send a message to other known as receiver; receiver at other end receives the message. The role of sender and receiver is not fixed and keep exchanging during communication, so in simple words, at a point, someone who sends the message is a sender and who receive the message is called receiver. In networking terms, sender and receiver are denoted as source and destination respectively.

Communication can be of many types depending upon the method of communication and the number of parties involved. Some of the scenarios are :

MeetMe helps you find new people nearby who share your interests and want to chat now! It’s fun, friendly, and free! Join 100+ MILLION PEOPLE chatting and making new friends. Meet New People. If you want to meet new people, FaceFlow makes it really easy to meet people from all around the world.There are public chatrooms in which you can chat live with other members and you can browse member profiles to make new friends.

  1. Simplex or one-way communication: Only one party is able to send the message and other parties can only receive.
  2. Duplex or two-way communication: Both parties can send and receive messages.

Meet & Chat Your girls Umeet#LiveDrinks. Chat.com is a free video chat website where you can watch up to 4 webcams at the same time in multiple chatrooms, invite people you like to a private chat, send instant messages, create and view profiles with photos, send and receive offline messages, fan and rate people, get email notifications when someone you like comes online, send tokens, and more. ‎Read reviews, compare customer ratings, see screenshots, and learn more about MeetMe - Go Live, Chat & Meet. Download MeetMe - Go Live, Chat & Meet and enjoy it on your iPhone, iPad, and iPod touch.

Duplex communication is a common way of communication and can be one-to-one (simple chat) or many-to-many (chat room)

Generally, in real-world communication is done directly using voice in an ideal situation (distance between communicating parties, identification of parties) where sender speak out and the intended receiver respond after listening. So, what is the medium of communication here? Indeed, it is the air which helps our voice to travel to the receiver and successful communication depends upon air (high wind and long-distance can cause trouble). In online or digital communication the role of air is played by network channel (coaxial cable, fiber optics, etc.) and communication is controlled by a server. A server is a program which regulates the communication between sender and receiver.

So, to create a PythonChat Application, one has to write a server program and client program/s (sender and receiver). Suppose, two parties Alice and Bob want to chat with each other and ask you to develop a chat application then being a developer you have to write a serverprogram and a clientprogram (different instance of the same program will be used by both Alice and Bob or even more users).

we will demonstrate the aforementioned scenario and will develop a PythonChat Application for Alice and Bob. Python has many modules which can help us to create network-related application, the socket is one of such popular default Python modules for low-level network programming. We will first list and explain the steps for server and client programs and then implement the same using Python.

Server script

Phone

Server program has all the logic to control and regulate the Chat, so most of the chat logic is implemented with a server program. So first step of communication is to identify the users, how server do this? In network communication, users are identified by a socket which is nothing but a combination of IP address and port address. So, for human understanding, Alice and Bob will be chatting but for a network, it is two sockets process which is sending and receiving bytes. Steps involved in this process is as follows:

  1. Create socket
  2. Communicate the socket address
  3. Keep waiting for an incoming connection request/s
  4. Connect to client
  5. Receive the message
  6. Decode the destination user and select the socket
  7. Send a message to the intended client
  8. Keep repeating step 5 & 6 as per users wish
  9. Exit i.e. end the communication by terminating the connection

Here’s the code for server-chat.py

Client script

Client script is run by the user, so the same client code will be run by a different user but each will have a separate socket so they will have their unique communication channel. Client script uses to be thin because it has very less work i.e. it only connect with the server and send and receive messages. The steps involved in client script are:

  1. Create a unique client socket per instance/user
  2. Connect to the server with given socket address (IP and port)
  3. Send and receive messages
  4. Repeat step 3 as per configuration
  5. Close the connection

Here’s the Code for client-chat.py

In the above program, each user has to run the client script separately after the server script is running. Once the client program connects to the server the client has to register itself as a user by giving a username, so the rest of the communication will be done using the username.

Steps forrunning the sample Chat application:

1. Open a terminal and Run the server-chat.py

2. Open a new terminal and run client-chat.py

a) Enter the username with a ‘#’ prefix. Example: #alice

b) Now, send the message to a user by following the format @username:message. Example: @bob:Hello, Bob! This is alice

3. Repeat step 2 for other users. (Maximum 5 users is allowed with server configuration i.e. server_socket.listen(5)

Limitations:

This demo on Python Chat Application has limited capabilities like the user get the message only after both parties enter the message to each other. Proper user validation etc. is not done.

Your

To Do:

  1. Test a simple cryptography feature.
  2. Add proper Authentication of the user.

Note: both scripts are based on various Internet sources.

I hope this article was helpful for you, please let me know in the comment section below.

Here’re some more Articles, you might be interested: Radeon x1650 drivers windows 7.

— Top 5 Python Web Frameworks to Learn

— Data Visualization in Python Using Simple Line Chart

— Here Are The Ten Best Programming Languages to learn

Recommended Training – Treehouse

From beginner to advanced, our recommended coding training is Treehouse.

Treehouse is an online training service that teaches web design, web development and app development with videos, quizzes and interactive coding exercises.

Meet Simplechat: Live Chat From Your Phone Number

Treehouse's mission is to bring technology education to those who can't get it, and is committed to helping its students find jobs. If you're looking to turn coding into your career, you should consider Treehouse.

Disclosure of Material Connection: Some of the links in the post above are “affiliate links.” This means if you click on the link and purchase the item, we will receive an affiliate commission. Regardless, we only recommend products or services we use personally and believe will add value to our readers.

Meet
  • Related Questions & Answers
  • Selected Reading
PythonProgrammingServer Side Programming

Meet Simplechat: Live Chat From Your Phone Call

MeetMeet simplechat: live chat from your phone calls

In this article we will see how to make a server and client chat room system using Socket Programming with Python.

The sockets are the endpoints of any communication channel. These are used to connect the server and client. Sockets are Bi-Directional. In this area, we will setup sockets for each end and setup the chatroom system among different clients through the server. The server side has some ports to connect with client sockets. When a client tries to connect with the same port, then the connection will be established for the chat room.

There are basically two parts. The server side and the client side. When the server side script is running, it waits for any active connection request. When one connection is established, it can communicate with it.

In this case we are using localhost. If machines are connected via LAN, then we can use IP addresses to communicate. The server will display its IP, and ask for a name for the server. From the client side, we have to mention a name, and also the IP address of the server to connect.

The Server Side Code

Meet Simplechat: Live Chat From Your Phone Numbers

The Client Side Code