This is a simple python code project using asyncio to generate and send data from a "sender" server to a "receiver" server. It was written using Python 3.10.5.
Pull down this repo from github, then create the environment (ex. using venv):
git clone https://github.com/dubswalker1/challenge1.git
cd challenge1
py -m venv env
./env/Scripts/activate
py -m pip install -r requirements.txt
Start the sender server (in one console):
python sender.py
Once started, the sender server will await a connection. Once connection is made (by the receiver), it will begin generating the sequence of binary output files and sending them to the connector.
Start the receiver server (in another console):
python receiver.py
Once started, the receiver should quickly begin receiving data from the sender. This will continue until 100 files have been generated by the sender and sent to the receiver. Once the final file is received, both the sender and receiver console output should both display matching totals for data sent and received on each end. Note: if started prior to the sender server, the receiver will continue to attempt to connect to the sender, until either it becomes available or a maximum retries of 10 is reached. At that point, the receiver will no longer attempt to connect and it will be necessary to restart (ctrl-C) the receiver to initiate the data transfer operation with the sender server.
To run the included pytest tests:
pytest
Note: 2/3 tests will fail if the sender and receiver servers have not been started before running pytest. Also, it is recommended that execution of pytest be performed after the sender server has completed sending to the receiver
and "waiting for something to send" is displayed in the console output.
The sender will create an "outputs" folder in the current working directory and generate 100 files named "file_<#>.bits" where # is just an incremented index per file. Each of these files contains the randomized quantity of binary data generated by sender. These files will be overwritten every time a connection is opened with the sender.
Sender and Receiver both output copious amounts of info to the console (sorry). When the sending of the 100 files is complete, sender will display a "total kb Generated" value, which should match the "Running Total Rcvd kb:" value output by receiver.
Meh, don't bother, this is just a coding challenge