First install pyformulas pip install pyformulas==0.2.7
Then run the server (receives the files):
For Server:
import pyformulas as pf
class server(pf.net.Stream):
file = bytes()
def on_receive(self, conn, buffer):
self.file += buffer
def on_disconnect(self, conn):
with open('file_%i' % self.port, 'wb') as file:
file.write(self.file)
servers = [server(port=1000+i) for i in range(3)]
Then the client (sends the files):
Client:
import pyformulas as pf
class send_file(pf.net.Stream):
def __init__(self, port, file, address):
self.file = file
super(send_file, self).__init__(port, address)
def on_connect(self, conn):
conn.send(self.file)
conn.disconnect()
filenames = ['0.txt', '1.wav', '2.bin'] # Put the filenames here
[ send_file(port=1000+idx, file=open(fname, 'rb').read(), address='server ip address') for idx, fname in enumerate(filenames) ]
Hope it helps, took reference from : https://pypi.org/project/pyformulas/
Cheers!