delphi - Indy 多端口 tcp 未在特定端口接收数据
问题描述
我有一个 TCP 服务器来从一些不同的端口读取数据。
端口 55000 连接到硬件设备,但其他端口将从软件客户端获取数据。
我的代码如下所示。
除 55000 外的所有端口都运行良好,但我没有在 55000 上获得任何数据。Wire-Shark 显示 TCP 层上的一切正常,Math-Lab 软件也可以接收数据,但 Indy 不能。
我怎样才能找到并解决问题?
ccsReCStatus := false;
offReCStatus := false;
case AContext.Binding.Port of
55000: begin
repeat
aByte := AContext.Connection.IOHandler.ReadByte;
inputOfflineStr := inputOfflineStr + chr(aByte);
if inputOfflineStr.Length>1000 then
begin
TThread.Synchronize(
nil,
procedure
begin
Memo14.Lines.Add( inputOfflineStr );
inputOfflineStr:='';
end);
end;
until offReCStatus = true;
end;
35758: begin
inputCcsStr :='';
repeat
aByte := AContext.Connection.IOHandler.ReadByte;
if aByte=$C0 then
begin
TThread.Synchronize(
nil,
procedure
begin
memo14.Lines.Add( datetimetostr(now) + ' :' + inputCcsStr );
inputCcsStr:='';
end);
end
else
begin
inputCcsStr := inputCcsStr + aByte.ToHexString;
AbLED482.Tag := DateTimeToUnix(now);
AbLED482.Checked := true;
end;
until ccsReCStatus = true;
end;
2222: begin
RStr:='';
repeat
aByte := AContext.Connection.IOHandler.ReadByte;
if (aByte = $C0) and (RStr='') then
begin
RStr:='';
end
else
if (aByte = $C0) and (RStr<>'') then
begin
TThread.Synchronize(
nil,
procedure
begin
memo14.Lines.Add( RStr );
RStr := '';
end);
end
else
begin
RStr:=RStr+chr(aByte);
end;
until ccsReCStatus = true;
end;
end;
解决方案
推荐阅读
- c++ - 生成的 ui_*.h 文件中的 QGroupBox 表示为指向 Int 的指针——为什么?
- c - 用 C 语言在游戏中测量时间和做动作
- ios - 如果应用程序被强制退出,则处理 IOS 远程通知
- html - Angular 6 Laravel 5.5:未提交单选按钮值
- php - 如何将简单的 MySQL 查询转换为 WordPress 元查询
- mongodb - $lookup 的 Foreign 字段可以是嵌套文档的字段吗?
- docker - 将 docker 日志重定向到文件
- java - 任务 ':app:compileDebugJavaWithJavac' 执行失败。在运行 React Native 项目时
- css - 在 Sass 中附加一个值
- ruby-on-rails - 通过添加日期和数字范围来创建唯一数字