Question

Implement your first Networking application that uses the Client-Server model. Using Python and either TCP or...

Implement your first Networking application that uses the Client-Server model. Using Python and either TCP or UDP Protocol, the application should do the following:

1. Client reads a line of characters (data) from its keyboard and sends data to server

2. Server receives the data and converts characters to uppercase

3. Server sends modified data to client

4. Client receives modified data and displays line on its screen

0 0
Add a comment Improve this question Transcribed image text
Answer #1

********** server.py********

import socket

name_host = socket.gethostname()
port = 8550 # port Number

socket = socket.socket()
socket.bind((name_host, port)) # bind Socket

socket.listen(2)
conn, add = socket.accept()
print("Connection Done" + str(add)) # print connection info

while True:
data_client = conn.recv(1024).decode() # receive data
if not data_client:
break
print("Client Message: " + str(data_client))
upper = data_client.upper() # Upper case conversion
conn.send(upper.encode()) # send data

conn.close() # close connection

*********** client.py*******

import socket

name_host = socket.gethostname()
port = 8550 #port

socket = socket.socket()   
socket.connect((name_host, port)) # connect to the server

data = raw_input("->")   

while data.lower().strip() != 'bye':
socket.send(data.encode()) # send message
data = socket.recv(1024).decode() # receive data
print('Data Received from server: ' + data)

data = raw_input("->")   

socket.close() # close the connection

*********** OUTPUT ********

server output:

client ouput :

Add a comment
Know the answer?
Add Answer to:
Implement your first Networking application that uses the Client-Server model. Using Python and either TCP or...
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
  • Use Python TCP socket to implement an application with client-server architecture. In this application, client must...

    Use Python TCP socket to implement an application with client-server architecture. In this application, client must read a line of characters from its input and send it to the server. The server must remove all non-alphanumeric characters from the input and send the modified data to the client. The client must receive the modified data and displays it on its screen.

  • Write TCP client and server programs in Python that the client gets a set of integers...

    Write TCP client and server programs in Python that the client gets a set of integers and the length of the set as command line arguments. Then the client sends the set to the server. Afterward, the server computes the total, the highest number, the lowest number, and the mean (in float) of the set and sends the results to the client. Finally, the client receives the results and prints them out.

  • In Python, make changes in the client code, so that the client allows the user to...

    In Python, make changes in the client code, so that the client allows the user to continue to send multiple requests until the user types in “Quit”. This means that the client process should not exit after the user sends one request and receives one response. Instead, the client process should be able to receive subsequent inputs from the user. You need to have a loop in the client code, so that it can accept the user request until the...

  • To develop a client/server application using TCP sockets and the C programming language that is capable...

    To develop a client/server application using TCP sockets and the C programming language that is capable of supporting multiple concurrent service requests from different clients. PROBLEM You are to use the Ubuntu operating system as well as both the client and the server programs. You are to modify your server program to process requests from more than one client concurrently. This means different clients may request either the same service or a total different one. The services supported by your...

  • 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...

  • In the last module you learned a formula for calculating bit rate, R = b/t, that...

    In the last module you learned a formula for calculating bit rate, R = b/t, that is the number of bits divided by the time. This formula expresses the number of bits that are transmitted over a circuit in a given period of time. In practice, however, we are not only concerned with the number bits transmitted, but also with the number of data bits transmitted over a circuit. The data bits are those that the sender decides to send...

  • This is in C. For this assignment we will write a simple database server. We will...

    This is in C. For this assignment we will write a simple database server. We will be creating a simple database of student records, so let’s describe these first. The format of a student record is as follows: typedef struct student {     char lname[ 10 ], initial, fname[ 10 ];     unsigned long SID;     float GPA; } SREC; Part One – the Server We will create a database server. The job of the server is to accept a...

  • on calculations can i see how did the expect come to the solution ,all the workout...

    on calculations can i see how did the expect come to the solution ,all the workout should be included QUESTION 1 A file of size F = 8 Gbits needs to be distributed to10 peers. Suppose the server has an upload rate of u = 68 Mbps, and that the 10 peers have upload rates of: u1 = 20 Mbps, u2 = 22 Mbps, u3 = 12 Mbps, u4 = 19 Mbps, u5 = 25 Mbps, u6 = 24 Mbps,...

  • 166 Chapter 8: TCP/IP Applications Getting Down to Business The way network communication all those ls...

    166 Chapter 8: TCP/IP Applications Getting Down to Business The way network communication all those ls and Os) goes in and out of a machine physically is through the NIC (network interface card). The way network communication goes in and out of a machine logically though, is through a program or service. A service is a program that runs in the background, independent of a logon, that provides functionalities to a system. Windows client machines, for instance, have a Workstation...

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
ADVERTISEMENT