Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need explanation for every line of this python codes. #Client.py import time, socket print( Welcome to Chat Room ) print(Initialising.... ) time.sleep(1) s =

I need explanation for every line of this python codes.

#Client.py

import time, socket

print(" Welcome to Chat Room ") print("Initialising.... ") time.sleep(1)

s = socket.socket() shost = socket.gethostname() ip = socket.gethostbyname(shost) print(shost, "(", ip, ") ") host = input(str("Enter server address: ")) name = input(str(" Enter your name: ")) port = 1234 print(" Trying to connect to ", host, "(", port, ") ") time.sleep(1) s.connect((host, port)) print("Connected... ")

s.send(name.encode()) s_name = s.recv(1024) s_name = s_name.decode() print(s_name, "has joined the chat room Enter [e] to exit chat room ")

while True: message = s.recv(1024) message = message.decode() print(s_name, ":", message) message = input(str("Me : ")) if message == "[e]": message = "Left chat room!" s.send(message.encode()) print(" ") break s.send(message.encode())

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Data Mining

Authors: Pang Ning Tan, Michael Steinbach, Vipin Kumar

1st Edition

321321367, 978-0321321367

More Books

Students also viewed these Databases questions