0% found this document useful (0 votes)
628 views36 pages

SIMPLE CHAT ROOM USING PYTHON Report

This document presents a project report on developing a simple chat room application using Python. It was created by P.KUMARAVARDHAN REDDY, P.V.BHANU PRAKASH REDDY, and G.KRISHNANJI REDDY under the guidance of their professor Dr. ANTONIDOSS. The report describes creating a chat room server that allows multiple clients to connect and communicate with each other by exchanging messages. It implements concepts like sockets and threading to enable communication between the server and clients.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
628 views36 pages

SIMPLE CHAT ROOM USING PYTHON Report

This document presents a project report on developing a simple chat room application using Python. It was created by P.KUMARAVARDHAN REDDY, P.V.BHANU PRAKASH REDDY, and G.KRISHNANJI REDDY under the guidance of their professor Dr. ANTONIDOSS. The report describes creating a chat room server that allows multiple clients to connect and communicate with each other by exchanging messages. It implements concepts like sockets and threading to enable communication between the server and clients.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 36

SIMPLE CHAT ROOM USING PYTHON

A PROJECT REPORT

Submitted by
P.KUMARAVARDHAN REDDY(19113141)
P.V.BHANU PRAKASH REDDY (19113121)
G.KRISHNANJI REDDY(19113132)

Under the guidance of


Dr. ANTONIDOSS
Associate Professor, CSE

in partial fulfillment for the award of the degree OF


BACHELOR OF TECHNOLOGY
IN COMPUTER SCIENCE AND
ENGINEERING
HINDUSTAN INSTITUTE OF TECHNOLOGY AND
SCIENCE
CHENNAI - 603 103
APRIL 2021
BONAFIDE CERTIFICATE

Certified that this Design project report “Smart Street Lighting System using IoT” is the bonafide
work of19113141 P.KUMARAVARDHAN REDDY,

19113121 P.V.BHANU PRAKASH,

19113132 G.KRISHNANJI REDDY who carried out the Project work under our supervision during the
academic year 2020- 21

DR. THANGAKUMAR, M.E., Ph.D., Dr. ANTONIDOSS

ASSOC. PROF & HEAD SUPERVISOR

Department of CSE ASSOCIATE PROFESSOR, CSE

INTERNAL EXAMINER EXTERNAL EXAMINER

Name: Name:

Designation: Designation:

PROJECT VIVA – VOCE CONDUCTED ON


TABLE OF CONTENTS

TITLE PAGE NO.


ACKNOWLEDGEMENT 4
ABSTRACT 6
INTRODUCTION 7
EXISTING SYSTEM 8
PROPOSED SYSTEM 9
SYSTEM ARCHITECTURE 11
ER DIAGRAM 12
BASE PAPER 13
LITERATURE SURVEY 14
MODULES 19
SOCKET PROGRAMMING 20
MULTI THREADING 21
USAGE 23
SERVER SIDE SCRIPT 24
CLIENT SIDE SCRIPT 27
OUTPUT 30
SCREENSHOTS 31
FUTURE ENHANCEMENT 32
CONCLUSION 33
INDIVIDUAL TEAM MEMBERS REPORT 34
REFERENCES 35
ACKNOWLEDGEMENT
First and foremost we would like to thank
ALMIGHTY who has provided us the strength to
do justice to our work and contribute our best to
it.
We wish to express our deep sense of gratitude
from the bottom of our heart to our guide
DR.ANTONIDOSS Associate Professor, School of
Computation, Computer Science and Engineering,
for his motivating discussions, overwhelming
suggestions, ingenious encouragement, invaluable
supervision, and exemplary guidance throughout
this project work.
We would like to extend our heartfelt gratitude to
Dr. Thangakumar, J,
M.E., Ph.D., Associate Professor & Head,
Department of Computer Science and Engineering
for her valuable suggestions and support in
successfully completing the project.
We wish to thank our Project Co-ordinator and
Panel members for keeping our project on the
right track. We would like to thank all the
teaching, technical and non-technical staff of the
Department of Computer Science and Engineering
for their courteous assistance.
We thank the management of
HINDUSTAN INSTITUTE OF TECHNOLOGY
AND SCIENCE for providing us the necessary
facilities and support required for the successful
completion of the project.
As a final word, we would like to thank each and
every individual who have been a source of
support and encouragement and helped us to
achieve our goal and complete our project work
successfully
ABSTRACT:

This article demonstrates How to set up a


simpleChat Room server and allow multiple
clients to connect to itusing a client side script.
The code uses the concept of socketsand
threading.

In this Application we create a server and number


of client’s interfaces in which the clients
communicate withserver using a socket module.
These sockets are interior endpoints for sending
and receiving data. A singlenetwork will have two
sockets. This program is implemented using TCP
socket [TCP refers to connectionoriented]. In this
socket will be connected to some port in the
machine or a localhost. In the case of client,
wewill connect a socket to that server, on the
same port that the server-side code is using
 INTRODUCTION:

 Now a days , We all are very active on social


media usingdifferent apps like massager and
what's app and withkeeping this is mind , we have
developed an application ofchatroom on pycharm
using python language .Basically ,this chatroom
project is a form of communicationthat utilizes
computer programs that allow for two -
wayconversations between users in real time .
Typically , theusers will connect to a chat server
using a chat client andmeet in a
chatroom . Conversations are then carried on
byreading the massages entered by the other users
in thechatroom and responding to them . The main
aim of this project is to attract the people towardsa
user - friendly interface . We have build a
chatroom whichis simple , secure and reliable
to massage all the people . Wewant to give people
better experience of chatting throughthis
application .
EXISTING SYSTEM:

As the chat applications which are in use requires


aninternet to communicate even the distance is
shortwhich make an major drawback in the
outskirts areawhere the internet connection is
poor, and theschools where internet cannot be
provided to largenumber of students, companies
which make theinformation more confidential
cannot be textedthrough internet. [5, 6, 7, 8, 9,
10, 11, 12, 13, 14, 15,16, 17, 18, 19, 20, 21, 22, 23,
24, 25, 26, 27, 28, 29, 30,31, 32, 33, 34, 35] It
needs an application which isrequired to be
installed by every user who needs tochat makes it
difficult. Most of the chat application doesn’t
provide end-to-end encryption which makesthe
texts more public
PROPOSED SYSTEM:

This application runs using a socket


programmingwhich is a combination of IP address
and a portnumber. This module consists of built-in
methodsthat are required for creating sockets and
help themto associate with each other. In this we
create aserver (denoted to manage network
resource) andclients (client request for services
from a server).This socket and socket API which
are used to sendmessage across various. These
are provided in theform of IPC i.e. Inter-Process
communication. Thenetwork can be a logical,
local network to thecomputer, or one that is
physically connected to thenetwork. We can
display this application in the GUI[Graphical user
interface] form using a module calledTkinter
which provides a great deal and informationon
using Tk from python and links to other source.
This makes the proposed system to use better
andmakes the user to feel comfortable while
using it.Sockets in python can be described as it
provide twolevel of network services which can be
accessed. Inthe low level we can access the
operating system byunderlaying the basic socket
support which allows toimplement clients and
servers for both connectionoriented and
connectionless protocols. Sockets alsohas library
to access the higher-level modules in thesuch as
FTP, HTTP etc
SYSTEM ARCHITECTURE:
1.Create a socket object and call the
socketfunction using that object
2.Bind the socket object in the server side which
ismust using a local address using bind()
prebuiltfunction.
3.Using listen() function we accept the
newconnections and arrange them in the
queueformat.
4.Using function connect() we clients connect
tothe local host of server
5.Accept the connections of clients using
thefunction accept() from the server side.
6.Accept the other connections of clients by
closingthe present client using the function
close().
 
7.Create an object from that read and write
thedata in the server side.
8.Repeat the same process in the client side.
9.Close the socket of both server and client
sideusing the function close()
ER DIAGRAM:
BASE PAPER:
LITERATURE SURVEY:

S.NO: TITLE AUTHOR: METHODOLOGY ADVANTAGES:


USED:

Chatroom Prof. Ajay ; Now a days , We all We have build a


1. Using
Python
Bhagya deep
Jena,
are very active on
social media using
chatroom whichis
simple , secure and
Project different apps like reliable to massage
Report massager and what's all the people
app and with
keeping this is mind

Free Vijayaranganathan Simple Chat Room It is developed


2. Download
Simple
Karuppa samy Using Python is a
open source you can
using Python and
Database None
Chat Download zip
Room
Using
Python
Project in
Python
with
source
code
TITLE METHODOLOGY
S.NO : AUTHOR : USED: ADVANTAGES :

Model ridwan Chats are bound A web-based


3. Implementation
Of Text And Video
bello ,mutiat to be an efficient
way of
Python Integrated
Development
Chats With Python disseminating Environment (IDE)
Ide Software synchronous and was developed by
asynchronous applying modern
information communication
techniques of text
and video chats

MODEL R. O. Bello, Integrated These activities


4. IMPLEMENTATION
OF TEXT AND
M. A.
Ogunrinde
Development
Environment
include source
code editing, auto-
VIDEO CHATS and O. B. (IDE), is a text completing, syntax
Bello editor that allows highlighting,
developers building
executable,
debugging, and
automated testing.
S.NO: TITLE METHODOLOGY
AUTHOR : USED: ADVANTAGES :

Multiparticipant David C. Multiparticipant chat Chat is a form of


5. chat analysis: A Uthus a,
survey David W.
has a variety of uses:
recreation, business ,
synchronous
textual
Aha distant software communication
development between a
collaboration community of
users. These users
converse in
chatrooms

Online ‘chat’ Graeme This article offers a My main argument


6. facilities as
pedagogic tools
Kirkpatrick critical assessment of
the ‘chat’component
is that features of
the virtual class-
of Black-board,a room (VC) give rise
generic intranet to negative
facility or platform reactions on the
part of tutors
S.NO TITLE AUTHOR METHODOLOG ADVANTAGES
: Y
: USED: :
THE SPECIFICITY Myroslava Communication has Our work mainly
7 OF THE INTERNET Zabotnova
SLANG
entered all the levels
of life whether you
based on informal
communication
IMPLEMENTATIO are a lecturer ora which is widely
N IN THE PROCESS student present-ed in chat
rooms

PLATO: The David The PLATO was A feature was later


8 Emergence of On-
Line Community
Woolley designed for
Computer based
added to term talk
that allowed the
Education participants to
switch to monitor
mode

MODULES:
1. SOCKET PROGRAMMING
2. MULTI THREADING
3. SERVER SIDE SCRIPT
4. CLIENT SIDE SCRIPT
5. OUTPUT

Socket programming :
Sockets can be thought of as endpoints in a
communication channel that is bi-directional
and establishes communication between a
server and one or more clients. Here, we set
up a socket on each end and allow a client to
interact with other clients via the server. The
socket on the server side associates itself with
some hardware port on the server-side. Any
client that has a socket associated with the
same port can communicate with the server
socket.

Multi-Threading:
A thread is a sub-process that runs a set of
commands individually of any other thread.
So, every time a user connects to the server, a
separate thread is created for that user, and
communication from the server to the client
takes place along individual threads based on
socket objects created for the sake of the
identity of each client. We will require two
scripts to establish this chat room. One to
keep the serving running, and another that
every client should run in order to connect to
the server.

Server Side:
Script The server-side script will attempt to
establish a socket and bind it to an IP address
and port specified by the user (windows users
might have to make an exception for the
specified port number in their firewall
settings, or can rather use a port that is
already open). The script will then stay open
and receive connection requests and will
append respective socket objects to a list to
keep track of active connections. Every time a
user connects, a separate thread will be
created for that user. In each thread, the
server awaits a message and sends that
message to other users currently on the chat.
If the server encounters an error while trying
to receive a message from a particular thread,
it will exit that thread.

Usage :
This server can be set up on a local area network by
choosing any on the computer to be a server node, and
using that computer’s private IP address as the server
IP address. For example, if a local area network has a
set of private IP addresses assigned ranging from
192.168.1.2 to 192.168.1.100, then any computer from
these 99 nodes can act as a server, and the remaining
nodes may connect to the server node by using the
server’s private IP address. Care must be taken to
choose a port that is currently not in usage. For
example, port 22 is the default for ssh, and port 80 is
the default for HTTP protocols. So these two ports
preferably, shouldn’t be used or reconfigured to make
them free for usage. However, if the server is meant to
be accessible beyond a local network, the public IP
address would be required for usage. This would
require port forwarding in cases where a node from a
local network (node that isn’t the router) wishes to
host the server. In this case, we would require any
requests that come to the public IP addresses to be re-
routed towards our private IP address in our local
network, and would hence require port forwarding.

Below is the Server side script :


import socket
import select
import sys
'''Replace "thread" with "_thread" for python 3'''
from thread import *

"""The first argument AF_INET is the address domain of the


socket. This is used when we have an Internet Domain with
any two hosts The second argument is the type of socket.
SOCK_STREAM means that data or characters are read in
a continuous flow."""
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

# checks whether sufficient arguments have been provided


if len(sys.argv) != 3:
print ("Correct usage: script, IP address, port number")
exit()

# takes the first argument from command prompt as IP address


IP_address = str(sys.argv[1])

# takes second argument from command prompt as port number


Port = int(sys.argv[2])

"""
binds the server to an entered IP address and at the
specified port number.
The client must be aware of these parameters
"""
server.bind((IP_address, Port))

"""
listens for 100 active connections. This number can be
increased as per convenience.
"""
server.listen(100)

list_of_clients = []

def clientthread(conn, addr):

# sends a message to the client whose user object is conn


conn.send("Welcome to this chatroom!")

while True:
try:
message = conn.recv(2048)
if message:

"""prints the message and address of the


user who just sent the message on the server
terminal"""
print ("<" + addr[0] + "> " + message)
# Calls broadcast function to send message to all
message_to_send = "<" + addr[0] + "> " + message
broadcast(message_to_send, conn)

else:
"""message may have no content if the connection
is broken, in this case we remove the connection"""
remove(conn)

except:
continue

"""Using the below function, we broadcast the message to all


clients who's object is not the same as the one sending
the message """
def broadcast(message, connection):
for clients in list_of_clients:
if clients!=connection:
try:
clients.send(message)
except:

Client-Side Script :
The client-side script will simply attempt to access the
server socket created at the specified IP address and
port. Once it connects, it will continuously check as to
whether the input comes from the server or from the
client, and accordingly redirects output. If the input is
from the server, it displays the message on the
terminal. If the input is from the user, it sends the
message that the user enters to the server for it to be
broadcasted to other users. This is the client-side
script, that each user must use in order to connect to
the server.

# Python program to implement client side of


chat room:
import socket
import select
import sys

server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)


if len(sys.argv) != 3:
print ("Correct usage: script, IP address, port number")
exit()
IP_address = str(sys.argv[1])
Port = int(sys.argv[2])
server.connect((IP_address, Port))

while True:

# maintains a list of possible input streams


sockets_list = [sys.stdin, server]

""" There are two possible input situations. Either the


user wants to give manual input to send to other people,
or the server is sending a message to be printed on the
screen. Select returns from sockets_list, the stream that
is reader for input. So for example, if the server wants
to send a message, then the if condition will hold true
below.If the user wants to send a message, the else
condition will evaluate as true"""
read_sockets,write_socket, error_socket = select.select(sockets_list,[],
[])

for socks in read_sockets:


if socks == server:
message = socks.recv(2048)
print (message)
else:
message = sys.stdin.readline()
server.send(message)
sys.stdout.write("<You>")
sys.stdout.write(message)
sys.stdout.flush()
server.close()

Output:
In the picture given below, a server has been
initialized on the left side of the terminal and a
client script on the right side of the terminal.
(Splitting of terminal done using tmux, ‘sudo apt-
get install tmux’). For initialization purposes, you
can see that whenever a message is sent by a
user, the message along with IP address is shown
on the server-side.

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.

Screenshots:
 
FUTURE ENHANCEMENT:
There are many applications which can be
createdusing these methods in which server holds
all theinformation where clients can communicate
withthat.It can be made by storing the
information in theservers where the client texts
automatically get areply for by creating a simple
chatbots.These can be used widely in many
schools or collegeswhere teachers can interact
with students or conductan exam

CONCLUSION:
This application can help many of the
professionalinstitutions and Universities like
schools, colleges andIT companies. So, we intend
to design thisapplication for LAN of these
organizations. The People could use many
features of this chatapplication to communicate
and brainstorm within aLAN. So, basically server
client application can beused to do various types
of quires such as medicalhelpline services,
customer report organization,which can be used
in different scenarios. Thisprovides the efficient
way of communicating withthe server, in which
these days it can be used tocreate a chat process
without any user interface orother man
operation

Individual team member’s report:

Individual objective:
1 19113141 P.KUMARAVARDHAN REDDY - Objective is to Implement all the
modules 1,2 of the project

2 19113121 P.V.BHANU PRAKASH – Objective is to study existing papers and


finding and module 3,4

3 19113132 G.KRISHNANJI REDDY– Objective is to Provide user friendly User


interface and module 5

Role of the team members:

4 19113141 P.KUMARAVARDHAN REDDY - ML model creation

5 19113121 P.V.BHANU PRAKASH - Technical paper & part of ML model

6 19113132 G.KRISHANJI REDDY - WEBAPP developer

Contribution of team members:

7 19113141 P.KUMARAVARDHAN REDDY - Implementation of all


modules and part of report and technical paper

8 19113121 P.V.BHANU PRAKASH - Requirement


gathering ,literaturesurvey and Technical paper and model 3,4

9 19113132 G.KRISHNANJI REDDY - Collecting dataset,Designing


webapp ,module 5

References:
1. Evaluation of an Interactive Tutorial for
Teaching the Central Limit
Theorem’,Teaching of Psychology 27: 289–
91 , ABERSON,BERGER,ROMERO
2. R. Friedland & D. Boden (eds) NowHere:
Space,Time and Modernity,pp.257–86.
LosAngeles,CA: University of California
Press.
3. Education Course’,FirstMonday
www.FirstMonday.dk/issues/issue4–12/hara/h
ttp://www.qassociates.co.uk/ (accessed
August 2002).
4. ‘A Profile of Teaching Techniques Used inthe
University Classroom’, Active Learning in
Higher Education3(1): 54–67
5. Blackboard. Details and product information
may be found athttp://www.qassociates.co.uk/
(accessed August 2002)
6.J. W. Hameed, J. and AbuSeileek. A. (2015).
“Using Text and Voice Chat Modes to
Enhance Students’ Performance in
Discourse Functions.” International Journal
of Learning Technology, 10(2), 114-136
7.Daim, T., Ha, A., Reutiman, S.,
Hughes, B., Pathak, U., Bynum, W.
and Bhatla, A. (2012). Exploring the
Communication Breakdown in Global
Virtual Teams. International Journal
of Project Management, 30(2), 199-212

8. Denstadli, J., Julsrud, T. and Hjorthol,


R. (2012). Videoconferencing as a
Mode of Communication: A
Comparative Study of the Use of
Videoconferencing and Face-to-Face
Meetings. Journal of Business and
Technical Communication – J BUS
TECH COMMUN. 26. 65-91.
10.1177/1050651911421125.

9. Comer, J, et al. (2015). Rationale and


Considerations for the Internet-Based
Delivery of Parent-Child Interaction
Therapy. Cognitive and Behavioral .

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy