In a while loop: Client needs to take a number from the user Client will send this number to the server The server will display a message that he got this number from this specific client (print IP address and port number of client) The server will check if this nummber is odd or even or zero The server will send the output of this check (even/odd/zero) to the client The client will print the output of the check to the user This while loop will break if the user enters 1000000 Please note that the port number of the client is assigned dynamically by OS

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
using python .
tcp client code
from socket import *
serverIP = '127.0.0.1'
serverPort = 12000
clientSocket = socket(AF_INET, SOCK_STREAM)
clientSocket.connect((serverIP,serverPort))
sentence = input('Input lowercase sentence:')
clientSocket.send(sentence.encode())
modifiedSentence = clientSocket.recv(1024)
print ('From Server:', modifiedSentence.decode())
clientSocket.close()
tcp server code
from socket import *
serverPort = 12000
serverSocket = socket(AF_INET,SOCK_STREAM)
serverSocket.bind(('',serverPort))
serverSocket.listen(1)
print ('The server is ready to receive')
while True:
connectionSocket, addr = serverSocket.accept()

sentence = connectionSocket.recv(1024).decode()
capitalizedSentence = sentence.upper()
connectionSocket.send(capitalizedSentence.encode())
connectionSocket.close()
  • In a while loop:
    • Client needs to take a number from the user
    • Client will send this number to the server
    • The server will display a message that he got this number from this specific client (print IP address and port number of client)
    • The server will check if this nummber is odd or even or zero
    • The server will send the output of this check (even/odd/zero) to the client
    • The client will print the output of the check to the user
    • This while loop will break if the user enters 1000000
  • Please note that the port number of the client is assigned dynamically by OS

Screenshot of Server cmd:

C:\Users\Student\Desktop\Python codes>python TCPServer.py
The server is ready to receive
The number is:  22     is received from:  ('127.0.0.1', 12)
The number is:  5     is received from:  ('127.0.0.1', 12)

 

Screenshot of client 1 cmd:

C:\Users\Student\Desktop\Python codes>python TCPClient.py

Enter the number: 22

The number is even

Enter the number: 5

The number is odd

Enter the number: 1000000

 

You need to submit 4 files (each 1.25 grade)

  • server code (.py or .txt)
  • client code (.py or .txt)
  • server cmd screenshot
  • client cmd screenshot

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 4 images

Blurred answer
Knowledge Booster
Files and Directory
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education