I would try it, but the whole program is needed, not just a part of it. I will try to write a new program that will differ from the current one by adding a control section for network traffic. It often happens in the network that some data will be lost, so it is necessary to count on it. This is the difference between LOCALHOST mode and real network mode.
The future program will work as follows:
1) HOST sends the file name of the uploaded file, for example, the file name has 20 characters.
2) The HOST waits for the CLIENT response to get 20 characters. But he is watching the time. If the answer does not arrive, for example, in a second, HOST sends the data again until the client confirms the correct size, after time limit CLIENT reset all incoming datas to zero and wait for new transfer.
3) HOST will send the filename (whether it is in the form of ASC numbers or a string directly, CLIENT waits until it has 20 values, then CLIENT sends the received string back to the guest and waits for confirmation. If this is not done correctly in the specified time, CLIENT resets the string to empty and HOST sends it again and waits for confirmation until this is not correctly transferred, and then proceeds:
4) Send the data SIZE for the transfer
5) Waiting for size confirmation if no match, resetting value and sending again
6) a packet and a predetermined size are sent.
7) if it does not arrive or does not reach the full size in tim limit for one packet, and the total size of the received data is less than the data value sent in point 4, this packet is reset and sent again.
It was because I was writing a game with LAN support. It went 5 times, but then, sometimes it stuck, and it ended with endless waiting for data that, although sent, was lost somewhere along the way. The error was that I did not realize this option at that time, and did not watch the time and did not send the specific data again.