Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Preferably Java/Python Create a program that receives serialized media files fro

ID: 3667664 • Letter: P

Question

Preferably Java/Python

Create a program that receives serialized media files from another computer through data network transfer. This program de-serialize the incoming transferred media file and insert it to a specific folder path to the user.

** If possible to create both clients of both computer stations that serialize and deseralize that would be very helpful.

The main idea behind this is being able to transfer media file from Client one ( Serialize Data) program to Client 2 (Deserialize Data) and put it in a specific path for the user.

Note: Client 1 is a Raspherry Pi 2 , therefore Python would be better.

As well in Client 1 specify a class to catch the media files from a specific Path folder from user station.

Explanation / Answer

Python program: To send data over network, you need to serialize it into an array of bytes, then deserialize it back. In Python, serialization of most objects can be done via pickle module. Here, file is send over the network. We first serilaize then de-serialize it. and store in the same folder the program is running. You can change the folder and append the name of the folder before file name. # Client program from socket import * import numpy from array import* # Set the socket parameters host = "localhost" port = 21567 buf = 4096 addr = (host,port) # Create socket UDPSock = socket(AF_INET,SOCK_DGRAM) a = open('some_file','r').read() # Send messages while (1): data = raw_input('yes or no') if data!= "yes": break else: if (UDPSock.sendto( pickle.dumps(a), addr)): print "Sending message" # Close socket UDPSock.close() # Server program from socket import * # Set the socket parameters host = "localhost" port = 21567 buf = 4096 addr = (host,port) # Create socket and bind to address UDPSock = socket(AF_INET,SOCK_DGRAM) UDPSock.bind(addr) # Receive messages while 1: output = open('some_file','w') data,addr = UDPSock.recvfrom(buf) L = pickle.loads(data) if not data: print "Client has exited!" break else: print " Received message '", output.write(L),"'" output.close() # Close socket UDPSock.close()