您的位置:首页 > 其它

发送一个记录数据包

2010-09-18 00:53 316 查看
1.服务器端:
type
TMSG001 = Packed Record //定义记录类型

userId: array[0..19] of char;

password: array[0..17] of char;

end;

PSendMSG=^TMSG001;//定义指针类型

var

pSend: PSendMSG;//定义指针

pSend^.userId := '001';//生成要发送数据

pSend^.password := '001';

_SocketS.Socket.Connections[i].SendBuf(pSend^, sizeof(TMSG001)); //发送数据

2.客户接收

type
TMSG001 = Packed Record //定义记录类型

userId: array[0..19] of char;

password: array[0..17] of char;

end;

PRecvMSG= ^TMSG001;

var

pRecv: PRecvMSG;

Socket.ReceiveBuf(pRecv^, SizeOf(TMSG001));

xxx := pRecv.userid;

xxx := pRecv.password;

如果一个结构体对应数据集中的一条记录,那么定义一个这样的结构体数组即可以对应一个数据集。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐