TRecord=packed record
i: Integer;
s: array [0..2] of string[200];
end;
var
a:array of TRecord;
const
room = $AABBCC01;//命令头
begin
setlength(a,100);
//对a赋值
.
.
socket.sendbuf(...);//问题在这里...
end;我怎样将一个命令头+a一起发送出去?
我又怎样接收这个数据?然后判断命令的值等于$AABBCC01,那么就取出a数组?
江湖救急,希望兄弟姐妹们帮帮忙,实在因扰的不行了
i: Integer;
s: array [0..2] of string[200];
end;
var
a:array of TRecord;
const
room = $AABBCC01;//命令头
begin
setlength(a,100);
//对a赋值
.
.
socket.sendbuf(...);//问题在这里...
end;我怎样将一个命令头+a一起发送出去?
我又怎样接收这个数据?然后判断命令的值等于$AABBCC01,那么就取出a数组?
江湖救急,希望兄弟姐妹们帮帮忙,实在因扰的不行了
解决方案 »
- 想在程序运行后可以让用户自己调节列表控件的整体宽度,怎么做?
- 告诉大家一个惊天的秘密
- 高分求救!SQLConnection1连接的SQLSERVER数据备份
- !!! dxDBTreeList 设置问题, 导致 Query.Insert ,或Append出错!
- 在线等待,解决马上放分,小问题
- delphi中存储过程问题。
- delphi怎么直接获取当年的年份
- 怎样提高Indy接收邮件的速度?
- 请问大家有没有从exe文件中找出一个窗口中写入数据与数据库中表的字段相对应的工具???
- 如何动态生成FastReport事件
- 求助:在delphi的自定义函数中引用其它变量出错
- delphi 7 FTP上传(支持TLS/SSL加密) 给100分!!
Sendbuf:pointer;
CurrPoint:pointergetmem(sendbuf,4+sizeof(Trecord));
CurrPoint :=SendBuf;
move(room,CurrPoint,4);
Currpoint :=pointer(longWord(CurrPoint)+4));
move(a,CurrPoint,sizeof(TRecord);
Sendbuf(Sendbuf,4+sizeof(Trecord));
freemem(SendBuf);
type
TRecord=packed record
i: Integer;
s: array [0..2] of string[200];
end;
...type
TPackHead = reocrd
Command: LongWord;
Length: Integer;
end;
var
PackHead: TPackHead;
a:array of TRecord;
const
room = $AABBCC01;//命令头
begin
PackHead.LongWord := room;
PackHead.Length := 100;
SetLength(a, PackHead.Length);
...
Socket.SendBuf(PackHead, sizeof(PackHead));
Socket.SendBuf(A, sizeof(TRecord) * PackHead.Length); SetLength(a, 0);
A := Nil;
end;
接收:
...type
TPackHead = reocrd
Command: LongWord;
Length: Integer;
end;
var
PackHead: TPackHead;
a:array of TRecord;
const
room = $AABBCC01;//命令头
begin
Socket.RecvBuf(PackHead, sizeof(PackHead));
if PackHead.Command <> room then Exit; SetLength(a, PackHead.Length);
... Socket.RecvBuf(A, sizeof(TRecord) * PackHead.Length);
//处理
...
SetLength(a, 0);
A := Nil;
end;