Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this lab you will write a simple chat application in Python using TCP sockets. The chat application consists of a chat server and a

In this lab you will write a simple chat application in Python using TCP sockets. The chat application consists of a chat server and a chat client. At any one time, the chat server is communicating with just one chat client. When the client and the server are done chatting, they exchange end messages which ends the session. The client and server read and write Unicode strings using the readUTF() and writeUTF() methods of DataInputStream and DataOutputStream respectively. After compilation, start the Chat server and then the Chat client in two separate command windows on the localhost. Let the client and server exchange a couple of messages from their respective windows and then end the session by exchanging the end message. I will do this in 2 computers using Spyder. Server: import socket s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind((socket.gethostname(), 1234)) s.listen(5) while True: # now our endpoint knows about the OTHER endpoint. clientsocket, address = s.accept() print(f"Connection from {address} has been established.") clientsocket.send(bytes("Hey there!!!","utf-8")) clientsocket.close() Client: import socket s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((socket.gethostname(), 1234)) full_msg = '' while True: msg = s.recv(8) if len(msg) <= 0: break full_msg += msg.decode("utf-8") print(full_msg) Where to put IP addresses and how to realize connection? Am i right with this process?

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

Database Design Application Development And Administration

Authors: Mannino Michael

5th Edition

0983332401, 978-0983332404

More Books

Students also viewed these Databases questions

Question

3. Go over a sample question first.

Answered: 1 week ago

Question

4. What are the current trends in computer software platforms?

Answered: 1 week ago