X
xzzcq
Unregistered / Unconfirmed
GUEST, unregistred user!
定义记录型数据type tlist=record cid:string[20]; cname:string[20]; ccode:string[20]; end;............................var testlist:tlist;............................按各网上的示例及以前大富翁中的做法,发送时的代码如下:procedure TchatForm.btn2Click(Sender: TObject); //发送记录集变量var i:Integer;begin testlist.cid:=edt1.Text; testlist.cname:=edt2.Text; testlist.ccode:=edt3.Text; if IsServer then for i:=0 to ServerSocket.Socket.ActiveConnections-1 do ServerSocket.Socket.Connections.SendBuf(testlist,SizeOf(tlist)) else ClientSocket.Socket.SendBuf(testlist,SizeOf(tlist));end;....................................服务器端接收的代码如下:procedure TchatForm.ServerSocketClientRead(Sender: TObject; Socket: TCustomWinSocket);var i:integer;begin for i:=0 to ServerSocket.Socket.ActiveConnections-1 do begin ServerSocket.Socket.Connections .ReceiveBuf(testlist,SizeOf(testlist)); edt1.Text:=testlist.cid; edt2.Text:=testlist.cname; edt3.Text:=testlist.ccode; end;end;...................................................客户端接收的代码如下:procedure TchatForm.ClientSocketRead(Sender: TObject; Socket: TCustomWinSocket);begin ClientSocket.Socket.ReceiveBuf(testlist,SizeOf(testlist)); edt1.Text:=testlist.cid; edt2.Text:=testlist.cname; edt3.Text:=testlist.ccode;end;...........................以上代码为什么不行呢? 请高手帮忙?