TCP或UDP文件传输 [英] TCP or UDP file transfer

查看:89
本文介绍了TCP或UDP文件传输的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我正在尝试构建一个C#windows应用程序,它将通过选择TCP或UDP逐行传输文件(两者都应该在同一个Windows应用程序上)并且传输的行应该显示在文本框1中,然后在另一个文本框2上接收到行...在相同的窗口上但是没有成功可以任意给我发送示例代码...

Hi,

I am trying to built a C# windows application which will transfer file line by line by selecting TCP or UDP (both should be on same windows app) and the line transferred should be displayed in a text box1 followed by line received at another text box2... on same windows but didn''t succeed can any1 send me sample code...

推荐答案

对不起,我们不发送密码,我们也没有为您的订单开发应用程序。这是一个问题&答案论坛,你注意到了吗?



首先,并非所有文件都包含行。即使对于由线组成的文件,line be line也是一个坏主意。通常,它由一些合理相同大小的块完成(除了最后一个)。



它也不能只是一个应用程序。当您使用两台不同的计算机时,总会有两个应用程序,每侧一个。但是,当然,您可能只想拥有一个应用程序,因为另一方面,应用程序可以是已经可用的某些Windows服务。特别是,它可以使用文件共享协议,FTP或HTTP(我没有提到这些协议的安全版本)。它们都是应用程序级协议( [ ^ ]。



另一方面,使用文件共享只是一个文件副本。基本上,您可以使用的类派生自类 System.Net.WebRequest 。请参阅:

http://msdn.microsoft.com /en-us/library/system.net.webrequest.aspx [ ^ ]。



最后,您可以使用自己的自定义应用程序级协议。在这种情况下,双方的申请都在你身上。它甚至可以是一个通用的应用程序,但你必须双方都有它。你可以在原始套接字的不同网络层工作(但你自己有点赞成:UDP,而不是TCP),到WCF的经典.NET远程处理。我试着在过去的答案中概述它:

我如何将byte []发送到其他电脑 [ ^ ],

通信用于LAN上的两个Windows应用程序。 [ ^ ]。



-SA
Sorry, we don''t send codes, and we don''t develop applications on your orders. This is a Questions & Answers forum, did you notice it?

First of all, not all files consist of lines. And even for the files consisting of lines, line be line is just a bad idea. Usually, it is done by some blocks of reasonable equal size (except perhaps a last one).

It also cannot be just one application. As you work with two different computers, there are always two applications, one on each side. But of course, you may want to have only one application just because on other side the application can be some Windows service which is already available. In particular, it can use file sharing protocol, FTP or HTTP (I did not mentions also secure versions of these protocols). They are all application level protocols ([^]).

On the other side, the use of file sharing is just a file copy. Basically, the classes you can use are derived from the class System.Net.WebRequest. Please see:
http://msdn.microsoft.com/en-us/library/system.net.webrequest.aspx[^].

And, finally, you can use your own, custom application-level protocol. In this case, the applications on both sides are on you. It can even be one generalized application, but you have to have it on both sides. You can work at different layers of networking from raw sockets (but do yourself a bit favor: UDP, not TCP), to "classical" .NET remoting to WCF. I tried to overview it in my past answers:
how i can send byte[] to other pc[^],
Communication b/w two Windows applications on LAN.[^].

—SA


这篇关于TCP或UDP文件传输的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆