F
F
First_Dominus2018-10-31 14:14:37
Java
First_Dominus, 2018-10-31 14:14:37

How to implement file sharing between devices on the network?

It is necessary to implement the exchange of files between devices in the local network.
What is the best way to do this? Make your own implementation of communication and file exchange via sockets or use some kind of protocol like ftp? What do you advise? I am going to use java.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Alexandrov, 2018-10-31
@First_Dominus

It all depends on the final task and the nuances in it, there are a lot of options in general:
1) Use ready-made protocols like ftp\scp\ssh\etc and their client-server implementations. In such a situation, you will have to put up with their problems / limitations / difficulties.
2) Go the stupid way, establish a connection, open a file stream and shove it into the socket, on the other side also open the stream and shove everything that came to the socket into it. Here you are already Pinocchio to yourself and you can pervert and solve problems yourself.
3) Go the right way and first write a technical task for yourself in which you will determine exactly what and how is necessary, the necessary measures for the reliability of the transmission and all possible problems and methods for solving them.
Those. figuratively speaking, we can take the principles of transmitting tcp \ ip packets as a basis:
1) Before starting the file transfer, send the crc of the file to the client, the client looked that there was no such thing and replied that it was waiting for reception. You can expand and, for example, answer that the file exists but has changed, which means that only changed blocks must be transferred.
2) The server, having received the client's consent, splits the file into chunks (some given block size)
3) The server sends crc to the client and a block, the client receives the crc and receives the block, then checks it with crc and replies that everything is OK, the server does the same with all the remaining blocks, if the server did not receive an ok from the client then send the block again. If you expand it, you can make a new response to the server that there is such a crc for such a block and let's go to the next one.
N) you refine all this to the desired result, for example, add block compression, number them so as not to send them sequentially, but there was the possibility of asynchronous transmission, add encryption, etc.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question