VB.Net UDP中的Filetransfer应用程序与TCP和(Filetransfer app in VB.Net UDP vs TCP and)

编程入门 行业动态 更新时间:2024-10-25 15:27:27
VB.Net UDP中的Filetransfer应用程序与TCP和(Filetransfer app in VB.Net UDP vs TCP and)

我正在VB.Net中开发一个文件传输应用程序

文件的大小各不相同,但最高可达10+ GB。

我已经创建了一个聊天应用程序作为测试。

在客户端,我运行此代码以连接到服务器。

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

我还可以用它来传输文件吗?

我想让应用程序通过防火墙和东西工作。

所以我认为我需要客户端上的传出数据通过端口80.在服务器上我希望能够在另一个端口上接收数据(例如8888)。 这可能吗?

最后一个问题是。 我应该为此目的使用什么协议TCP或UDP。

对不起三合一问题:)

谢谢你的协助。

I'm developing a filetransfer app in VB.Net

The sizes of the files vary, but can get up to 10+ GB.

I already create a chat app as a test.

On the clientside 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 app to work through a firewall and stuff.

So I think I need the outgoing data on the client to go through port 80. On the server I want to be able to receive the data on another port (E.g. 8888). Is this possible?

And final question is. What protocol should I use for this purpose TCP or UDP.

Sorry for the three-in-one question :)

Thanks for helping me out.

最满意答案

传输文件:是的,您可以很好地使用可靠的网络流来传输文件。 至少这些文件的数据。 您必须自己进行文件系统管理(在正确的文件夹中创建目标文件等)。

TCP / UDP:由于您需要可靠性和流量控制来通过Internet传输大块数据,因此您可能需要使用TCP。 TCP的其他功能,如按顺序传送和错误检测也不会受到影响。 如果使用UDP,你可能最终会自己实现所有这些,浪费了你很多时间。

防火墙:应用程序的客户端防火墙应该没有问题,除非它们非常严格并且只允许传出HTTP连接。 但是,必须可以从Internet访问服务器端口,即您希望配置服务器端网络,以便将对公共IP和所选端口的传入连接请求转发到服务器上的所选端口。 查找“端口转发”或“端口NAT”以获取更多信息。 即使不是不可能,绕过双方的防火墙和NAT也要困难得多。 别试试。

Transfer Files: Yes you can very well use a reliable network stream to transfer files. Well at least the data of those files. You have to do the file system management (creating the destination file in the right folder, etc.) yourself.

TCP/UDP: As you need reliability and flow control to transfer big chunks of data over the internet, you might want to go for TCP. Also the other features of TCP like in-order delivery and error detection won't hurt. You would probably end up implementing all those yourself if using UDP, wasting a lot of your time.

Firewall: There shouldn't be a problem with firewalls on the client side of your application, unless they are really very strict and only allow outgoing HTTP connections. But the server port has to be accessible from the internet, that is you want your server side network configured such that incoming connection requests to your public IP and your chosen port are forwarded to the chosen port on your server. Look up "port forwarding" or "port NAT" for more information. Bypassing firewalls and NATs on both sides is really much more difficult if not impossible. Don't try.

更多推荐

本文发布于:2023-08-01 22:25:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1365763.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用程序   UDP   VB   Net   app

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!