0% found this document useful (0 votes)
13 views7 pages

DCL - Experiment 2 1

The document outlines an experiment for a Distributed Computing Lab course, focusing on implementing a chat application using socket programming in Python. It includes software code for both server and client, observations, conclusions, and answers to questions regarding socket programming. The experiment emphasizes the differences between TCP and UDP protocols and the importance of server-client architecture in distributed systems.

Uploaded by

sawantshubham873
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views7 pages

DCL - Experiment 2 1

The document outlines an experiment for a Distributed Computing Lab course, focusing on implementing a chat application using socket programming in Python. It includes software code for both server and client, observations, conclusions, and answers to questions regarding socket programming. The experiment emphasizes the differences between TCP and UDP protocols and the importance of server-client architecture in distributed systems.

Uploaded by

sawantshubham873
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

G. V.

Acharya Institute of Engineering & Technology


Computer Engineering Department
Program: Sem VIII

Course: Distributed Computing Lab (CSL802)

Faculty: Narayan Kharje

Experiment No. 2

A.1 Aim: To Implement Group Communication as a Chat application using socket


programming.

PART B
(PART B: TO BE COMPLETED BY STUDENTS)

Roll No. Name:

Class: Batch:

Date of Experiment: Date of Submission:

Grade:
B.1 Software Code written by student:

● Server.py import

time, socket, sys

new_socket = socket.socket() host_name =


socket.gethostname() s_ip =
socket.gethostbyname(host_name) port =
8080

print("Welcome to the Chat Room\n")


new_socket.bind((host_name, port))
print("Binding Successful!") print("This is
your IP: ", s_ip) name = input('Enter name:

1
') new_socket.listen(1) conn, add =
new_socket.accept()
print("Received connection from ", add[0]) print('Connection
Established. Connected From: ',add[0]) client =
(conn.recv(1024)).decode() print(client + ' has connected.')

conn.send(name.encode()) while True:


message = input('Me : ')
conn.send(message.encode()) message =
conn.recv(1024) message =
message.decode() print(client, ':',
message)

● Client.py import

time, socket, sys

socket_server = socket.socket() server_host


= socket.gethostname() ip =
socket.gethostbyname(server_host) sport =
8080

print("Welcome to the Chat Room\n") server_host =


input('Enter friend\'s IP address:') name = input('Enter
Friend\'s name: ') socket_server.connect((server_host, sport))

socket_server.send(name.encode()) server_name =
socket_server.recv(1024) server_name =
server_name.decode()

print(server_name,' has joined...') while True: message


= (socket_server.recv(1024)).decode()
print(server_name, ":", message) message =
input("Me : ") socket_server.send(message.encode())
B.2 Input and Output:

2

● Client.py

3
4
B.3 Observations and learning:
In this experiment, we learnt socket programming to establish a server-client network and
implemented a chat application in python.

B.4 Conclusion:
We successfully implemented a chat application using socket programming in python. B.5
Question of Curiosity.
Q1: Server Socket consists of port address and IP address or only port address. ANS:
- A server socket has a port address as well as an IP address. Every device on a TCP/IP
network requires an IP address. The gadget is identified by its IP address. A socket is

5
associated with a port number so that the TCP layer can identify the application to
which data is being transmitted.

Q2: Compare UDP socket programming and TCP socket programming ANS:

Feature TCP UDP

Connection Connectionless protocol with no


status Requires an established requirements for opening,
connection to transmit data maintaining, or terminating a
(connection should be closed connection
once the transmission is
complete)

Able to sequence Unable to sequence


Data
sequencing

Guaranteed Can guarantee delivery of data to Cannot guarantee delivery of data to


delivery the destination router the destination

Speed Slower than UDP Faster than TCP

Broadcasting Does support Broadcasting


Does not support
Broadcasting

Optimal use
Used by HTTPS, HTTP, SMTP, Video conferencing, streaming,
POP, FTP, etc DNS, VoIP, etc

Error checking Extensive error checking and Basic error checking mechanism using
acknowledgement of data checksums

Q3. The distributed system uses a ___________architecture to break down the complexity of
system design. The _______________ is the distributed software that drives the distributed
system while providing transparency of heterogeneity at the platform level.
1. Layered, Middleware
2. Message-passing, CORBA
3. Tree, RPC

6
4. Loosely coupled, MPI

ANS: 1. Layered Middleware


Q4: The ____________________allows the server and client to authenticate each other and
to negotiate an encryption algorithm and cryptographic keys before the application protocol
transmits or receives its first byte of data.
1. SSL record protocol
2. SSL TCP segment
3. SSL handshake protocol
4. None of these

ANS: 3. SSL handshake protocol

You might also like