WriteBuffer 发送大小只能是255?

wealsh 2006-05-07 05:11:53
text:=memo1.text;大于255的字节都不能被发送?
Idtcpclient1.WriteBuffer(text,SizeOf(text));
...全文
222 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
string默认是长串,其实是一个指针,这样WriteBuffer写结构的时候肯定越界了。
这么定义:
type
Sendtest = packed record
command:string[5];
Text:array[0..4095] of char;
end;
wealsh 2006-05-07
  • 打赏
  • 举报
回复
type

Sendtest = packed record
command:string[5];
Text:string;
end;

改成这样不行啊?一发送就断开了连接
getit911 2006-05-07
  • 打赏
  • 举报
回复
MyRecord = Packed Record,用这样定义Record,否则因为内存对齐,造成Sizeof返回不正确的值。
wealsh 2006-05-07
  • 打赏
  • 举报
回复
type

Sendtest = record
command:string[5];
Text:string[255]; //不加上255服务端读不到??加上以后又不能完全发送?
end;

Sendtest.command:='text';
Sendtest.Text:=memo1.text;
Idtcpclient1.WriteBuffer(Sendtest,SizeOf(Sendtest));
wealsh 2006-05-07
  • 打赏
  • 举报
回复
Idtcpclient1.WriteBuffer(text[1],lenght(text));
text 改为数组??
getit911 2006-05-07
  • 打赏
  • 举报
回复
Idtcpclient1.WriteBuffer(text[1],lenght(text));
应该是这样写吧。

1,593

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 网络通信/分布式开发
社区管理员
  • 网络通信/分布式开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧