使用 INDY 10 在 Delphi 中发送和接收数据流
这是在 Delphi 中发送和接收数据流的延续。
我将使用 TCP/IP 发送图像,然后使用 UDP 更新该图像中的更改,方法是将图片分成小块并仅发送发生重大更改的块,然后客户端将在客户端上修补这些块。老照片。
每 15 秒,整个图像就会使用 TCP/IP 更新一次。
服务器中的图片将通过网络摄像头进行更新。 (就像视频流)。我已经在delphi中创建了一个运动检测器和片段收集器,它们工作得很好。
以下是我在实施中遇到的问题
1.在INDY 10中使用TIDUDPServer/client发送和接收数据流(>indy 10中的示例代码)我使用的是delphi XE2
2.UDP中一个数据包可以支持的最大数据大小是多少
3.当我双击 IdUDPServer1.onUDPRead 事件时,IDE 产生错误
TArray <System.Byte>
我认为最终错误是由于 XE2 中新引入的命名空间造成的。
使用以下内容代替 indy 怎么样?
Sockets.TTcpClient
Sockets.TTcpServer
Sockets.TUdpSocket
This is a continuation of Sending and receiving data streams in Delphi.
I am going to send an image using TCP/IP and then going to update the changes in that image using UDP by dividing the picture in to small pieces and sending only the pieces that are having major changes then the client will patch those pieces on the old picture.
every 15 seconds the whole image is updated using TCP/IP.
The picture in server will be updated by webcam. (Like a video Stream).I have already created a motion detector and piece collector in delphi which are working perfectly .
following are my problems in implementing
1.Sending and receiving data streams using TIDUDPServer/client in INDY 10 (sample code in >indy 10) I am using delphi XE2
2.what is the maximum size of data one Packet in UDP can support
3.when i double click on IdUDPServer1.onUDPRead event the ide producing an error with
TArray <System.Byte>
I think the final error is because of newly introduced namespace in XE2.
what about using the following instead of indy
Sockets.TTcpClient
Sockets.TTcpServer
Sockets.TUdpSocket
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Indy 的 UDP 组件根本不支持流,仅支持
TIdBytes
和String
(使用TIdBytes
在内部处理)。如果要发送/接收TStream
数据,则必须将数据复制到中间TIdBytes
或从中复制数据。UDP 理论上限制为 ~64kb,但实际上受操作系统限制要小得多。通常每个数据包发送的大小不应超过 8-16kb。
这是一个已知的 Delphi 编译器错误,在过去的几个版本中尚未修复。 IDE 正在生成基于 RTTI 的代码,但编译器无法正确使用该代码。这不是 Indy 的 bug,但 Embarcadero 已经意识到了这个问题。在他们(最终)修复编译器错误之前,您可以通过在运行时而不是在设计时在代码中分配
OnUDPRead
事件处理程序来解决它。Indy's UDP components do not support streams at all, only
TIdBytes
andString
(which is internally handled usingTIdBytes
). If you want to send/receiveTStream
data, you have to copy the data to/from an intermediateTIdBytes
.UDP is theoretically limited to ~64kb, but realistically much smaller by OS restrictions. You should generally not send more than 8-16kb per packet.
That is a known Delphi compiler bug that has not been fixed yet in the past few releases. The IDE is generating code based on RTTI that the compiler does not consume correctly. That is not an Indy bug, but Embarcadero is aware of the issue. Until they (finally) fix the compiler bug, you can get around it by assigning the
OnUDPRead
event handler in code at runtime instead of at designtime.