简体   繁体   English

如何使用TCP(VB.NET)发送和接收大图像

[英]How to send and receive a large image using tcp (VB.NET)

I need to send and receive a large image between programs running on different machines within the same network. 我需要在同一网络中不同计算机上运行的程序之间发送和接收大图像。

I've looked at using upd. 我看过使用upd。 However, I ran into problems with the size of the packets and (after breaking the image into smaller pieces to get past this problem) the number of packets needing to be processed all at once - and ultimately packet loss. 但是,我遇到了数据包大小的问题,并且(在将图像分解成较小的碎片以解决此问题之后)遇到了一次需要处理的数据包数量的问题,最终导致数据包丢失。

I've also thought of sending the image by storing it in a common file folder and receiving it by using file watcher as a trigger. 我还考虑过通过将图像存储在公用文件夹中来发送图像,并通过使用文件监视程序作为触发器来接收图像。 However, this just adds further complexities in setup where common folders don't already exist. 但是,这只会增加通用文件夹还不存在的设置的复杂性。

Assuming I'm barking up the right tree looking at TCP, can someone point me to/provide an example of how to send an image file using it (VB.NET would be ideal). 假设我在盯着TCP的正确树,有人可以指出/提供使用该文件发送图像文件的示例(VB.NET是理想选择)。 Also, are there practical limits to TCP package sizes? 另外,TCP包大小是否有实际限制?

If I am not barking up the right tree, and there is an easier way to do this I'd surely appreciate some guidance/examples. 如果我没有正确选择树,并且有一种更简单的方法可以做到这一点,我一定会感谢一些指导/示例。

看一下Socket.SendFile方法 (MSDN)。

Consider using WCF (Windows Communication Foundation) with TCP binding. 考虑将WCF(Windows Communication Foundation)与TCP绑定一起使用。 You can even use streaming mode. 您甚至可以使用流模式。 You don't need to worry about packet size, etc. You only need to be careful about the size of the image. 您无需担心数据包大小等问​​题。您只需要注意图像的大小即可。 You will need to modify some settings in the service configuration file to allow large messages to be sent. 您将需要修改服务配置文件中的某些设置,以允许发送大消息。

You can make a proof-of-concept application within a day (no fancy UI, just the absolute minimum functionality). 您可以在一天内完成概念验证应用程序(没有花哨的UI,只有绝对的最低功能)。 And that is because you are new to the technology. 那是因为您是该技术的新手。 Someone that has worked with WCF beore can do it in about one hour at normal speed. 与WCF beore合作过的人可以正常速度在大约一小时内完成操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM