add password in client code python (enter password to allow send and receive message UDP) e. 1234
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 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()
Accounting Information Systems
ISBN: 978-0133428537
13th edition
Authors: Marshall B. Romney, Paul J. Steinbart