Session 03 - Python for Forensics
The code here is to support the Session 03 lecture.
udpClient.py
import socket, sys
def client():
host = "127.0.0.1"
port = 5000
try:
clientSocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
print("[+] UDP socket successfully created!")
except socket.error as error:
print("[E] There was an issue with the socket, due to %s" %(error))
print("[!] Exiting...")
sys.exit()
message = input(" (send message): ")
while message.lower().strip() != 'bye':
clientSocket.sendto(message.encode(), (host, port))
message, addr = clientSocket.recvfrom(1024)
print(" (received message): " + message.decode())
message = input(" (send message): ")
clientSocket.close()
if __name__ == '__main__':
client()