Question

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

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. 4.1 Provide your server and client code as well as the message exchanges (screenshots of server and client command windows) to Blackboard.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
  1. Python Socket Server:
    import socket
    serv = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    serv.bind(('0.0.0.0', 8080))
    serv.listen(5)
    while True:
    conn, addr = serv.accept()
    from1 = ''
    while True:
    data = conn.recv(4096)
    if not data: break
    from1 += data
    print (from1)
    conn.send("I am SERVER\n")
    conn.close()
    print ('client disconnected')
      

  2. Python Socket Client:

    import socket
    client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    host = ('', 6166)
    client.connect(host)
    client.send("I am CLIENT\n")
    from_server = client.recv(4096)
    client.close()
    print (from_server)

we open to command prompts one for client and another for server run at a time.

Add a comment
Know the answer?
Add Answer to:
In this lab you will write a simple chat application in Python using TCP sockets. The...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In this assignment, you design a simple chat room in the form of a network application which uses the services of a TCP/IP computer network. Your design should have a clientserver architecture in whic...

    In this assignment, you design a simple chat room in the form of a network application which uses the services of a TCP/IP computer network. Your design should have a clientserver architecture in which the server is multi-threaded. Then, you need to implement the server-side of the chat-room application in Java (implementing the client-side is optional). The server maintains a list (an ArrayList will work well) of all the active connections. It will listen on a port for a new...

  • Using python 3 to create the UDP Ping Clien and server. Using UDP sockets, you will...

    Using python 3 to create the UDP Ping Clien and server. Using UDP sockets, you will write a client and server program that enables the client to determine the round-trip time (RTT) to the server. To determine the RTT delay, the client records the time on sending a ping request to the server, and then records the time on receiving a ping response from the server. The difference in the two times is the RTT. The ping message contains 2...

  • I need help with this assignment, please; Programming Assignment 3: UDP Pinger Lab In this lab,...

    I need help with this assignment, please; Programming Assignment 3: UDP Pinger Lab In this lab, you will study a simple Internet ping server written in the Java language, and implement a corresponding client. The functionality provided by these programs is similar to the standard ping programs available in modern operating systems, except that they use UDP rather than Internet Control Message Protocol (ICMP) to communicate with each other. (Java does not provide a straightforward means to interact with ICMP.)...

  • Risk management in Information Security today Everyday information security professionals are bombarded with marketing messages around...

    Risk management in Information Security today Everyday information security professionals are bombarded with marketing messages around risk and threat management, fostering an environment in which objectives seem clear: manage risk, manage threat, stop attacks, identify attackers. These objectives aren't wrong, but they are fundamentally misleading.In this session we'll examine the state of the information security industry in order to understand how the current climate fails to address the true needs of the business. We'll use those lessons as a foundation...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT