rust TOKIO async TCP client and UDP logger example

Job ID: 34409756

Budget: $10 – $141 AUD

Create a single example rust program using the tokio (https://tokio.rs/) async framework that implements the two following functions to interface to a networked device.

1. Async TCP client that connects to a device on TCP port 9760
a) Create an async reader function that reads messages from the device (not polling)
These messages are variable-length binary messages and must be read as bytes values (Not a text string).
Format in hex (<u8> 0x16, <u8> Length, <u8> 1 .. Length payload )
Messages are variable length unto 255 bytes (2-byte header + 253 bytes data)
Eg 16 04 00 0E 00 00

You need to read the first two bytes (ie 0x16, 0x04) to determine the variable payload length. The variable payload length is in the second byte, in this example case 4 bytes. Then you need to read the variable length payload to consume the entire message based on the length. Append a single-line HEX format of the bytes read for each full message (as above) to a file name messages.txt.
Immediately re-queue async next read for the next message.

b) Create an async periodic timer, that every minute, sends a 3-byte binary message to the device, in hex 0x16,0x0,0x0 on TCP port 9760.

2. In the same application create async logger listening on UDP port 30303 to log messages broadcast from the device.
   Read the messages when receive and append them to a log file  named log.txt     
Messages are text strings terminated (0xD, 0xA)
   Log messages in text format  

I can make PCAP files (TCP and UDP) and the device available on the internet to test with for TCP code.

All code must be async not blocking or polling code.

Program should be developed to run as a console application.
Related categories: Local Area Networking RUST Programming