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

CMPTR
3rd Edition
ISBN:9781337681872
Author:PINARD
Publisher:PINARD
Chapter22: Integrating Word, Excel, Access, And Powerpoint
Section: Chapter Questions
Problem 4QY
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
CMPTR
CMPTR
Computer Science
ISBN:
9781337681872
Author:
PINARD
Publisher:
Cengage