Well i want to transfer different chunks of data to client machine , by different i mean the data sent could be either code or a particular function , i have used basic socket program in order to transfer the content , but how do i make the client system help differentiate between these contents , i am aware of the concept of metadata, but dont know how to apply it in here .
Example :
This following is the basic psuedo code on how it has to work
Server side :
# basic socket program
> conn.send(data)
Slave side:
#basic socket program
> d = conn.recv(1024)
> if d is code: execute the code
> else: store the data
It sounds like your simply looking to serialize python objects.
Look at the pickle (and cPickle) module. Pickle is the python serialization format, which will allow you to transfer python objects as strings. Make sure to take note of what can, and can’t be pickled as well.
If your client needs to differentiate between data and code, you need to have something in your protocol which distinguishes them. A simple example would be to send your data using json. You could put the strings into dictionaries, and differentiate them by key: