SIMPLE CHAT ROOM USING PYTHON Report
SIMPLE CHAT ROOM USING PYTHON Report
A PROJECT REPORT
Submitted by
P.KUMARAVARDHAN REDDY(19113141)
P.V.BHANU PRAKASH REDDY (19113121)
G.KRISHNANJI REDDY(19113132)
Certified that this Design project report “Smart Street Lighting System using IoT” is the bonafide
work of19113141 P.KUMARAVARDHAN REDDY,
19113132 G.KRISHNANJI REDDY who carried out the Project work under our supervision during the
academic year 2020- 21
Name: Name:
Designation: Designation:
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.
"""
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 = []
while True:
try:
message = conn.recv(2048)
if message:
else:
"""message may have no content if the connection
is broken, in this case we remove the connection"""
remove(conn)
except:
continue
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.
while True:
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.
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 objective:
1 19113141 P.KUMARAVARDHAN REDDY - Objective is to Implement all the
modules 1,2 of the project
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