Implementing file transfer over LAN using ftp server in C # or Java

Question:

How to transfer files from one device to another, provided that you are connected to the same Wi-Fi network?

It is necessary that when you select a file (we are going to transfer it to another device), an ftp server or another implementation (http) is launched in the background, and the address of this server is displayed on the screen in order to download this file from another device (at this address).

For example: ftp://192.168.2.123:2137 or http: // …..: 8080

where: 192.168.2 … – device ip-address

When we enter this address on another device (in the application), or in the browser, this file is downloaded.

Please tell me how to implement this idea, examples in the form of code are welcome.

Answer:

Create a class that implements TCP or UDP sockets and work through them. Everything is quite trivial. For the web, you can transfer web headers, respectively, check on the server if there is a connection, then we try to send it a file. You can read the FTP specification and, accordingly, implement a similar technology on sockets in Sharp. There are a lot of examples of code for a tcp server and a local http server on the Internet. There are several links on Habré.

Scroll to Top