Hi. I didn't celebrate success with networking ... but ....
If one party sends information about the start of the transmission, it is good to wait for the set time (set yoursefl by your program) to confirm. Then the sending party sends the amount of data it wants to transfer. He waits for confirmation from the counterparty and then begins to send data and waits for a specified amount of time to confirm receipt from the counterparty. Preferably, the counterparty sends the size of the received data. If it does not send anything within the set limit, you must resolve it in the program so that both parties resume the new transmission (transfer reset). You'll never get the data you won't catch. These are my experiences gained when writing a network version of BattleShip game, that worked on the network .... 3x correctly and then stuck, just because I waited for the client to receive data in infinite time... (my version not check the time) And be careful. What works in localhost mode perfectly, may not work in the actual network.