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
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
Chapter22: Integrating Word, Excel, Access, And Powerpoint
Section: Chapter Questions
Problem 4QY
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()
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()
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
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps with 4 images
Knowledge Booster
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.Recommended textbooks for you