Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UDP file transferring in Delphi

I am writing a program to transfer files through a lan computers, it's been a while I'm searching for file transferring methods in Delphi. I found UDP is a good solution, but there is a problem: in every example or article I found there was a client program beside a server program, but my program have to send and receive to/from every computer in network, there is no specific server or client, something like p2p, I don't want to make a computer Server and another one Client, what should I do? I searched Indy articles too, it's working in Server/Client mode too (as far as I found).

enter image description here

like image 633
Armin Taghavizad Avatar asked Dec 27 '22 09:12

Armin Taghavizad


2 Answers

UDP can work in broadcast mode, which is what you need. But such UDP broadcasts are not routable outside the current network (i.e. they are blocked by routers), so you have to implement something more complex if your project needs to be accessible outside the primary physical network.

Do not reinvent the wheel! If you want to see some working source implementing this concept, see Ares Galaxy:

"Delphi self-organizing p2p network project featuring high scale capability and fast broadcast-type search system. Client supports multi-source file transfers, partial file sharing, built-in audio/video player and decentralized chat rooms".

The source code files are available from SourceForge. You could re-use/adapt the P2P network layer for your needs - but take attention to the license terms of Ares source code, if you use it in your projects.

like image 79
Arnaud Bouchez Avatar answered Jan 18 '23 22:01

Arnaud Bouchez


Have a look at Indy's TIdTrivialFTP and TIdTrivialFTPServer components. TFTP is a UDP-based file transfer protocol.

like image 38
Remy Lebeau Avatar answered Jan 19 '23 00:01

Remy Lebeau