Question
add password in client code python (enter password to allow send and receive message UDP) e. 1234 then correct the server code python and using
add password in client code python (enter password to allow send and receive message UDP) e. 1234
then correct the server code python
and using Wireshark then screen shout for data messages, by using oracle, seed-Ubuntu 20.04
codes in this website
https://linuxhint.com/send_receive_udp_python/
server.py
import socket
import sys
if len(sys.argv) == 3:
# Get "IP address of Server" and also the "port number" from
argument 1 and argument 2
ip = sys.argv[1]
port = int(sys.argv[2])
else:
print("Run like : python3 server.py
exit(1)
# Create a UDP socket
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
# Bind the socket to the port
server_address = (ip, port)
s.bind(server_address)
print("Do Ctrl+c to exit the program !!")
while True:
print("####### Server is listening #######")
data, address = s.recvfrom(4096)
print("\n\n 2. Server received: ", data.decode('utf-8'), "\n\n")
send_data = input("Type some text to send => ")
s.sendto(send_data.encode('utf-8'), address)
print("\n\n 1. Server sent : ", send_data,"\n\n")
client.py
import socket
import sys
if len(sys.argv) == 3:
# Get "IP address of Server" and also the "port number" from argument 1 and argument 2
ip = sys.argv[1]
port = int(sys.argv[2])
else:
print("Run like : python3 client.py
exit(1)
# Create socket for server
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, 0)
print("Do Ctrl+c to exit the program !!")
# Let's send data through UDP protocol
while True:
send_data = input("Type some text to send =>");
s.sendto(send_data.encode('utf-8'), (ip, port))
print("\n\n 1. Client Sent : ", send_data, "\n\n")
data, address = s.recvfrom(4096)
print("\n\n 2. Client received : ", data.decode('utf-8'), "\n\n")
# close the socket
s.close()
Step by Step Solution
There are 3 Steps involved in it
Step: 1
To add a password to the client code in Python you can modify the clientpy code as follows import so...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started