Filetransfer application in VB.Net UDP vs TCP and

I am developing a filetransfer application in VB.Net

File sizes vary, but can reach 10+ GB.

I am already creating a chat application as a test.

On the client side, I run this code to connect to the server.

Dim clientSocket As New System.Net.Sockets.TcpClient() Dim serverStream As NetworkStream clientSocket.Connect("127.0.0.1", 80) 

Can I also use this to transfer files?

I want the application to work through a firewall and stuff.

So, it seems to me that I need the outgoing data on the client to go through port 80. On the server, I want to be able to receive data on another port (for example, 8888). Is it possible?

And the last question. Which protocol should I use for this purpose TCP or UDP.

Sorry for asking three questions :)

Thanks for helping me.

+4
source share
3 answers

File transfer. Yes, you can very well use a reliable network stream to transfer files. Well, at least the data of these files. You need to manage the file system yourself (by creating the destination file in the right folder, etc.).

TCP / UDP: since you need reliability and flow control to transfer large pieces of data over the Internet, you can go for TCP. In addition, other TCP functions, such as delivery in order and error detection, will not hurt. You will probably end up implementing all of this yourself, if you use UDP, spend a lot of time.

Firewall: There should be no problems with firewalls on the client side of your application, if they are not very strict and allow only outgoing HTTP connections. But the server port must be accessible from the Internet, that is, you want your server network to be configured so that incoming requests to connect to your public IP address and the port you select are redirected to the selected port on your server. See โ€œport forwardingโ€ or โ€œNAT portโ€ for more information. Bypassing firewalls and NAT on both sides is indeed much more difficult, if not impossible. Do not try.

+6
source

To transfer very large files like yours, you need to break them into small pieces. This will help you configure the application, which may resume after a network error. For this reason, like many others, you also want to choose TCP for your transport protocol. UDP may be faster than TCP, but it does not have the detection and correction of errors that you will need for secure data transfer.

Here is a C # article on how to transfer large files from both the client and server perspectives. If this is what you are looking for, you just need to translate the code to VB.NET (which a translator can automatically do for yours).

http://codetechnic.blogspot.com/2009/02/sending-large-files-over-tcpip.html

Basically, the code converts the file into an array of bytes, and then sends it over the network / Internet. Since you can choose the port you use, you will not have a problem with the firewalls when it is located. On the client side, when the client initiates the connection, it will be outbound initialization, so it will exit the network without any problems.

+1
source

I assume you are on Windows, so just use BITS

Have a nice .net sharpbits wrapper

0
source

Source: https://habr.com/ru/post/1335606/


All Articles